3:53 pm - Wednesday March 24, 6630

String Program using lastIndexOf(int ch) method

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

// String Program using lastIndexOf(int ch) method*/

class index_last{
public static void main(String[] args){
String strin="Its dark here please switch on the lights";
System.out.println("Given string :"+strin);
/* lastIndexOf(int ch) method Searches for the last occurrence of a character  in the String and returns it index position.
If that character doesn't exist then returns -1.
*/
System.out.println(" Last index of 'e' in the given string: "+ strin.lastIndexOf('e'));
}
}

 

Output:
E:\String>javac index_last.java

E:\String>java index_last
Given string :Its dark here please switch on the lights
Last index of ‘e’ in the given string: 33
*/

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply