Tuesday, 17 June 2014

indexOf (int ch, int fromIndex)

public int indexOf(int ch, int fromIndex)
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index. 

class StringIndexOfFrom{
 public static void main(String args[]){
  String s1 = new String("wxyzbab");
  System.out.println("s1 = " + s1);
  
  System.out.print("Character b at index ");
  System.out.println(s1.indexOf('b', 5));
 }
}

Output
s1 = wxyzbab
Character b at index 6

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment