isBlank, strip, repeat, lines and formatted remove the need for a utility class for everyday string work.
String messy = " Java Coding Hub ";
System.out.println("strip = [" + messy.strip() + "]");
System.out.println("isBlank = " + " ".isBlank());
System.out.println("repeat = " + "-".repeat(20));
System.out.println("formatted = " + "%s has %d tools".formatted("JCH", 5));
System.out.println("lines = " + "a\nb\nc".lines().toList());
System.out.println("chars>2 = " + Stream.of("ab", "abc", "a").filter(s -> s.length() > 2).toList());
strip = [Java Coding Hub]
isBlank = true
repeat = --------------------
formatted = JCH has 5 tools
lines = [a, b, c]
chars>2 = [abc]
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-30