Java Reference
In-Depth Information
If you want to know which character is at a certain position, you can use the charAt()
<< "e"
This tells us that the character "e" is at position 1 . If you were thinking that it should be
"H" , this is because the first letter is classed as being at position 0 (you'll find that count-
ing usually starts at zero in programming!).
If you want to find where a certain character or substring appears in a string, we can use
the indexOf() method:
<< 0
If a character doesn't appear in the string, -1 will be returned:
<< -1
If we want the last occurrence of a character or substring, we can use the lastIn-
dexOf() method:
<< 7
The concat() method can be used to concatenate two or more strings together:
<< "JavaScriptNinja"
"Hello".concat(" ","World","!");
<< "Hello World!"
A shortcut for string concatenation is to use the + symbol to add the two strings together:
Search WWH ::

Custom Search