public class StringContains {
public static void main(String args[]) {
String str = "jsp servlet tutorial", str1 = "420_9211", str2, str3;
CharSequence char0 = "sp", char1 = "_";
boolean result = str.contains(char0);
System.out.println("Method returns true here: " + "'" + result + "'");
result = str1.contains(char1);
System.out.println();
System.out.println("Return True: " + "'" + result + "'");
System.out.println();
str2 = " jsp tutorial, servlet tutorial, java tutorial";
System.out.println("Return False: " + "'"+ str2.contains("jsp servlet") + "'");
}
}
|