In Java having the following
printf("%-5s Hello %s %n", "", "There!")
It prints
Hello There!
Where exists 5 empty spaces located to the left.
Until here it works how is expected, but ...
I want to know if is possible: How avoid the "" declaration and change %-5s to something that printf can interpret that represents an empty space?
I mean: for example %-5e where e is assumed to represent an empty character and therefore is not necessary anymore declare "" explicitly.
Something similar like %n where it does not required an argument through the printf. Is clear that %s requires an argument, in this case "" but being curious if my request can be accomplished.
I read the Formatter javadoc for that required feature and seems does not exist.
I already did do a research on SO and some suggested solutions is use the + within printf, but to be honest it reduces readability
Therefore the goal is (formatted for better presentation):
From: printf("%-5s Hello %s %n", "", "There!")
To: printf("%-5e Hello %s %n", "There!") // %-5e is the functionality I need or looking for
5spaces beforeHello There!. How aboutSystem.out.printf(" ".repeat(5) + " Hello %s %n", "There!");?+? I don't want lost readabilityJava-8now.printf("%11s %s %n", "Hello", "There!")?