Java Data Type Tutorial - Java StringBuilder .lastIndexOf ( String str)








Syntax

StringBuilder.lastIndexOf(String str) has the following syntax.

public int lastIndexOf(String str)

Example

In the following code shows how to use StringBuilder.lastIndexOf(String str) method.

public class Main {
/*from   w  w  w . j  a  v  a2 s  .  c  o  m*/
  public static void main(String[] arg) {
    StringBuilder phrase = new StringBuilder("java2s.com");
    int position = phrase.lastIndexOf(".com");

    System.out.println(position);
  }

}

The code above generates the following result.