89
How It Works
A new method was included in the String class in Java 11. It read contents of files
processing each line separately and returns a stream of lines
extracted from the string
based on line terminators, such as a line feed character (\n),
a carriage return character
(\r), or a carriage return immediately followed by a line feed (\r\n).
3-8. Repeating Strings
Problem
You want to repeat strings.
Solution
Use the java.lang.String.repeat(int) method as follows.
String nameString = "luciano";
String repeatString = nameString.repeat(3);
It returns the following output.
lucianolucianoluciano
How It Works
Java 11
introduced the repeat method, which returns the concatenation of a string
repeated as many times as provided by the int (count) parameter.
3-9. Changing the Case of a String
Problem
A portion of your application contains case-sensitive string values. You want to change
all the strings to uppercase or lowercase before they are
processed to avoid any case
sensitivity issues down the road.
Chapter 3 StringS