state the purpose and return data type of index of and compare to
Answers
Answered by
3
Explanation:
The java string indexOf() method returns index of given character value or substring. If it is not found, it returns -1. The index counter starts from zero.
Internal implementation
public int indexOf(int ch) {
return indexOf(ch, 0);
}
Signature
There are 4 types of indexOf method in java. The signature of indexOf methods are given below:
No. Method Description
1 int indexOf(int ch) returns index position for the given char value
2 int indexOf(int ch, int fromIndex) returns index position for the given char value and from index
3 int indexOf(String substring) returns index position for the given substring
4 int indexOf(String substring, int fromIndex) returns index position for the given substring and from index
Similar questions