Java String lastIndexOf Example
String class lastIndexOf method example
String class lastIndexOf method example. This example shows you how to use lastIndexOf method.This method Returns the index within this string of the last occurrence of the specified character.
Syntax:-lastIndexOf(int ch)
Here is the code:-
/**
* @(#) LastIndexOfstring.java
*Program that Returns the index within this string of the last occurrence of the specified character.
* @Version 02-May-2008
* @author Rose India Team
*/
public class LastIndexOfstring
{
public static void main(String args[])
{
// Declaration of String
String s = "Welcome to Rose india Rose";
//Displaying the given String definrd above
System.out.println(s);
//Returns the index within this string of the last occurrence of the specified character.
System.out.println("INDEX OF 'Rose' IN THE STRING IS=" + s.lastIndexOf('o'));
}
} |
null
|