Wednesday 18 June 2014

lastIndexOf (String str, int fromIndex)

public int lastIndexOf(String str, int fromIndex)
return the index of the last occurrence of the specified substring, searching backward from the specified index, or -1 if there is no such occurrence.

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

Output
Last index of "da" is : 6


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment