Java 11: New String methods (isBlank, strip, repeat, lines)

Java 11 added handy String helpers for whitespace and repetition.

Code
System.out.println("   ".isBlank());
System.out.println("  hi  ".strip() + "|");
System.out.println("ab".repeat(3));
"one\ntwo\nthree".lines().forEach(System.out::println);
Output
true
hi|
ababab
one
two
three
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-07-26