Sunday 22 June 2014

startsWith (String prefix, int toffset)

public boolean startsWith(String prefix, int toffset)
Tests if the substring of this string beginning at the specified index starts with the specified prefix.

class StringStartsWithOffset{
 public static void main(String args[]){
  String str = "Self Learning Java";
  
  System.out.println(str.startsWith("Learning", 5));
  System.out.println(str.startsWith("Abcd", 5));
 }
}

Output
true
false


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment