新版本的变更 / Java 11

// *** before: ***
String s = "  text  ";
boolean blank1 = s.trim().isEmpty();
String clean1 = s.trim();                 // trim knows nothing about Unicode spaces
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 3; i++) sb.append("ab");
String repeat1 = sb.toString();

// *** in version 11: ***
boolean blank2 = "  \t ".isBlank();       // true
String clean2 = "  text  ".strip();       // "text", Unicode aware
String left = "  text  ".stripLeading();
String right = "  text  ".stripTrailing();
String repeat2 = "ab".repeat(3);          // "ababab"

"one\ntwo\nthree".lines()                // a stream of lines
        .map(String::strip)
        .forEach(System.out::println);

System.out.println(blank1 + " " + clean1 + " " + repeat1);
System.out.println(blank2 + " [" + clean2 + "] [" + left + "] [" + right +
                   "] " + repeat2);