Stringof Method In In Java Code Example

Snippet 1
  public int length()
-----------------------
String x = "01234567";
System.out.println( x.length() ); // returns "8"
 
Snippet 2
  public boolean contains(“searchString”)

String x = “Java is programming language”;
System.out.println(x.contains(“Amit”)); // This will print false
System.out.println(x.contains(“Java”)); // This will print true