Java Reference
In-Depth Information
The countBetween method finds the first and last positions of the char-
acter ch in the string str . If the character does not occur twice in the
string, the method returns -1 . The difference between the two charac-
ter positions is one more than the number of characters in between (if
the two positions were 2 and 3, the number of characters in between is
zero).
Several overloads of the method indexOf search forward in a string, and
several overloads of lastIndexOf search backward. Each method returns
the index of what it found, or 1 if the search was unsuccessful:
Method
Returns Index Of...
first position of ch
indexOf(int ch)
indexOf(int ch, int start) first position of ch
start
first position of str
indexOf(String str)
indexOf(String str, int
start)
first position of str
start
last position of ch
lastIndexOf(int ch)
lastIndexOf(int ch, int
start)
last position of ch
start
last position of str
lastIndexOf(String str)
Search WWH ::




Custom Search