java tutorial - Java Strings indexOf() method - java programming - learn java - java basics - java for beginners
Learn Java - Java tutorial - Java strings indexof - Java examples - Java programs
Description
Java Strings indexOf() method in Java has the following options:
- public int indexOf (int ch) - Returns the index in the given line of the first occurrence of the specified character or -1 if the character does not occur.
- public int indexOf (int ch, int fromIndex) - It returns a index in the given line of first occurrences of specified character then it starts a search at the specified index. -1 if this character does not occurs, returns -1.
- int indexOf (String str) - Returns the index in the given line of the first occurrence of the specified substring. -1 if this substring does not occur, -1 is returned.
- int indexOf (String str, int fromIndex) - Returns the index in the given line of the first occurrence of the specified substring starting at the specified index. If not, -1 is returned.
Syntax
Options
Detailed information about the parameters:
- ch is a character;
- fromIndex - index to start the search (from);
- str is a string.