java.lang.StringBuffer lastIndexOf(String str)

Syntax:

public int lastIndexOf(String str)

Java Code Example :

This java example source code demonstrates the use of lastIndexOf(String str) method of StringBuffer class. Initially the code assigns a string “javatutorialhq.com” as initial contents of the string buffer. Then we use the indexof method to get the last index on the stringbuffer object where we find the string “a”.

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) method example

lastIndexOf(String str) method example

Suggested Reading List :

References :