Wednesday 18 June 2014

lastIndexOf (String str)

public int lastIndexOf(String str)
Returns the index within this string of the last occurrence of the specified substring or -1 if there is no such occurrence.

class StringLastIndexOfStr{
 public static void main(String args[]){
  String s1 = "wxyzabdabdda";
  
  System.out.print("Last index of \"da\" is : ");
  System.out.println(s1.lastIndexOf("da"));
 }
}

Output
Last index of "da" is : 10

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment