Java 11 doesn't have a lot of language unequivocal features. Along these lines, it was bewildering to see 6 new procedures getting introduced in Java String Clas.
Let's look at these new String class procedures one by one.
CopyString s = "abc"; System.out.println(s.isBlank()); s = ""; System.out.println(s.isBlank()); s = "\t \t"; System.out.println(s.isBlank());
Copyfalse true true
Notice that "\t" is considered as a void zone character codepoint in Unicode.
I am using >jShell to execute the code bits without truly making a java file.
CopyString s1 = "Hi\nHello\rWassup"; System.out.println(s1); List
lines = s1.lines().collect(Collectors.toList()); System.out.println(lines);
This technique is valuable to process multi-line strings with one line at a time.
strip()will remove driving and trailing whitespaces. In any case,
stripLeading()will oust simply driving whitespaces and
stripTrailing()will clear simply trailing whitespaces.
CopyString s2 = " Hello, \tWorld\t "; System.out.println("#" + s2 + "#"); System.out.println("#" + s2.strip() + "#"); System.out.println("#" + s2.stripLeading() + "#"); System.out.println("#" + s2.stripTrailing() + "#");
Copy# Hello, World # #Hello, World# #Hello, World # # Hello, World#
CopyString s3 = "Hello\n"; System.out.println(s3.repeat(3)); s3 = "Do"; System.out.println(s3.repeat(2));
Java String class has a huge amount of utility procedures. Regardless, all these new utility strategies will be incredibly important since we won't have to worry over staying in contact with them ourselves and thinking about whether they spread all the phenomenal circumstances related to different sorts of Unicode characters or not.