Add java11-features module: runnable demos and captured output for the ankurm.com java11-features article

This commit is contained in:
2026-10-20 17:13:58 +00:00
parent 77c782abbf
commit 8b9447a393
19 changed files with 223 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
import java.util.stream.Collectors;
/** The String additions in Java 11: isBlank, lines, strip, repeat. */
public class StringMethods {
public static void main(String[] args) {
String em = String.valueOf((char) 0x2003); // EM SPACE: whitespace to strip(), not to trim()
String padded = em + " hello " + em;
System.out.println("trim() length : " + padded.trim().length());
System.out.println("strip() length : " + padded.strip().length());
System.out.println("isBlank(\" \") : " + " ".isBlank() + " isEmpty: " + " ".isEmpty());
System.out.println("lines() : " + "a\nb\r\nc".lines().collect(Collectors.toList()));
System.out.println("repeat(3) : " + "ab".repeat(3));
System.out.println("stripLeading : [" + " x ".stripLeading() + "] stripTrailing: [" + " x ".stripTrailing() + "]");
}
}