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
 

Copyright © Code Fetcher 2020

 

 

Published

Leave a comment

Your email address will not be published. Required fields are marked *