Java String lastIndexOf(String str)Example
String class lastIndexOf(String str) method example
String class lastIndexOf(String str) method example. This example shows you how to use lastIndexOf(String str) method.This method Returns the index within this string of the rightmost occurrence of the specified substring.
Here is the code:-
/**
* @(#) LastIndexOf2string.java
*Program that Returns the index within this string of the rightmost occurrence of the specified substring.
* @Version 02-May-2008
* @author Rose India Team
*/
public class LastIndexOf2string
{
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 rightmost occurrence of the specified substring.
System.out.println("INDEX OF 'Rose' IN THE STRING IS=" + s.lastIndexOf("Rose"));
}
} |
null
|