logo

Java String LastIndexOf() Method


Show

Description

This technique revisits the index of the preceding amount of the value in the character succession symbolized by this entity that is less than or identical to fromIndex, or -1 if the value does not come before that point.

Syntax

Here is the syntax of this method:

int lastIndexOf(int ch)

Parameters

Here is the detail of parameters −

  • ch − a character.

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 Intellinuts.com");
      System.out.print("Found Last Index :" );
      System.out.println(Str.lastIndexOf( 'o' ));
   }
}

This will produce the following result:

Output

Found Last Index :27

Here at Intellinuts, we have created a complete Java tutorial for Beginners to get started in Java.