Java 11 - New String Features
- schick09
- Dec 27, 2024
- 1 min read
Updated: Aug 11, 2025
Java 11 introduced several new features, but the most notable and useful to most of our daily work routines resolves around new String class methods. We will discuss a few here.
String.isBlank() returns a boolean value indicating whether or not a string is empty or contains only white space. It returns true if the String is empty or contains only whitespace.
String.lines() returns a Stream of lines extracted from a string. So if you have a String composed of several new lines (/n), it will convert that String into a Stream where each element in the Stream is one of those lines. Then from there, you can convert the Stream to a List, etc.
String.repeat() just repeats the given String how every many times you request. So something like "*".repeat(10) would give you a string containing "**********".
Here's a link to our GitHub location to access examples of all the new String methods discussed above: https://github.com/daveschickconsulting/java_11_examples/tree/main/src/funwithjavastringimprovements




Comments