WEB DEVELOPER SITE
PHP7
 

Java String lastIndexOf(String str) Method



Returns the index within this string of the rightmost occurrence of the specified substring


Syntax

Here is the syntax of this method โˆ’

public int lastIndexOf(String str)

Parameters

Here is the detail of parameters โˆ’

  • str โˆ’ a string.

Return Value

  • This method returns the index.

Example


import java.io.*;
public class Test {

   public static void main(String args[]) {
      String Str = new String("Welcome to Welookups.com");
      String SubStr1 = new String("We" );
      System.out.print("Found Last Index :" );
      System.out.println( Str.lastIndexOf( SubStr1 ));
   }
}

Run example ยป