Java String Method lastIndexOf

This method take a string parameter as input and return the last index value of parameter string in specified string. If string not found then it returns -1.
The second overloaded method find the string from fromindex position.

Signature

public int lastIndexOf(String str)
public int lastIndexOf(String str, int fromIndex)

Parameters

str- to search in String
fromindex- to search str from specified index

Return

Return the last index value of parameter str in specified string. If str not found then it returns -1

Example

Result