The lastIndexOf() method of the String class allows a user to search the last occurrence of a character or a substring from a given string. This method is overloaded in several ways. In all ways, the method returns the index at which the character or the substring was found, or return -1 on failure.
To search for the last occurrence of a character, the following is used:
here, ch specifies the character being searched.
To search for the last occurrence of a substring, the following is used:
To search the occurrence of a character or a substring from a starting index, the following are used:
here, startIndex specifies the point from which the search for a character or a substring begins. The search begins from startIndex to zero.
Click here to get free scja SCJA exam practice questions. Pass SUN CX310-019 - SCJA