Strings In Depth14 / 18
Up next

Iterate lines

class Main {
    public static void main(String[] args) {
        String text = """
                first
                second
                third""";
        // lines() returns a Stream<String>, one per line
        text.lines().forEach(System.out::println);
    }
}
What you're solving

text block plus lines()