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