Saturday 14 June 2014

contains (CharSequence s)

public boolean contains(CharSequence s)
Returns true if and only if this string contains the specified sequence of char values.

class StringContains{
 public static void main(String args[]){
  String s1 = new String("abcd");
  
  System.out.println("is s1 contains a " + s1.contains("a"));
  System.out.println("is s1 contains bc " + s1.contains("bc"));
  System.out.println("is s1 contains abd " + s1.contains("abd"));
 }
}

Output
is s1 contains a true
is s1 contains bc true
is s1 contains abd false



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment