Skip to content

Instantly share code, notes, and snippets.

@swetharnaik
Last active May 29, 2021 07:42
Show Gist options
  • Save swetharnaik/359df025b0bf5e028a3b48ec9e941c67 to your computer and use it in GitHub Desktop.
Save swetharnaik/359df025b0bf5e028a3b48ec9e941c67 to your computer and use it in GitHub Desktop.
Java11 - String Methods
public class StringMethods {
public static void main(String[] args) {
String s = "\tJAVA11 is the latest LTS version\t";
System.out.println(s+"!!!");
System.out.println(s.strip()+"!!!");
System.out.println(s.trim()+"!!!");
String blankOrEmpty = "";
System.out.println("isEmpty: " + blankOrEmpty.isEmpty() +
" isBlank: " + blankOrEmpty.isBlank());
blankOrEmpty = "\t ";
System.out.println("isEmpty: " + blankOrEmpty.isEmpty() +
" isBlank: " + blankOrEmpty.isBlank());
String pleaseRepeat = "*";
System.out.println("Repeated 5 times: " + pleaseRepeat.repeat(5));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment