java.lang.StringBuffer lastIndexOf(String str,int fromIndex)


public int lastIndexOf(String str,int fromIndex)

Java Code Example :

This java example source code demonstrates the use of lastIndexOf(String str,int fromIndex) method of StringBuffer class. Initially the code assigns a string “” as initial contents of the string buffer. Then we use the lastIndexof method to get the last index on the stringbuffer object where we find the string “a” in cosideration with another method argument fromIndex.

This is very useful to work with substring method of StringBuffer class. On this example we will also learn how to use the lastIndexOf method to work with substring.

Sample Output :

Running the above example source code will give the following output

lastIndexOf(String str,int fromIndex) method example

lastIndexOf(String str,int fromIndex) method example

Suggested Reading List :

References :