Sunday, 22 June 2014

startsWith (String prefix)

public boolean startsWith(String prefix)
Tests if this string starts with the specified prefix. Returns true if the string starts with given prefix, else false.

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

Output
true
false




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment