Given the following code
public class TextBlock {
public static void main(String[] args) {
String indentedText = """
hello
indented
world
""";
System.out.println(indentedText);
}
}
The output is as follows (mind the leading spaces):
hello
indented
world
How to obtain String value like below (without unnecessary leading spaces)?
hello
indented
world
You can manipulate indentation by changing closing quotes position in the code ("""). For example
Would produce
but
will produce