Java Data Type Tutorial - Java String.lastIndexOf(int ch, int fromIndex)








Syntax

String.lastIndexOf(int ch, int fromIndex) has the following syntax.

public int lastIndexOf(int ch,  int fromIndex)

Example

In the following code shows how to use String.lastIndexOf(int ch, int fromIndex) method.

 
public class Main {
  public static void main(String args[]) {
    String s = "this is a test from java2s.com.";

    System.out.println(s);
    System.out.println("lastIndexOf(t, 60) = " + s.lastIndexOf('t', 60));

  }
}

The code above generates the following result.