Wednesday 18 June 2014

lastIndexOf (int ch, int fromIndex)

public int lastIndexOf(int ch, int fromIndex)
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index.

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

Output
Last index of d is : 6


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment