The last newline is not automatically stripped in Java.
jshell> var s = """
...> hello world
...> """;
s ==> "hello world\n"
You have to escape it: jshell> var s = """
...> hello world\
...> """;
s ==> "hello world"