Pad a String with Spaces in Java

Ashok Veer | June 12, 2020 |

Since Java 1.5 we can use the method java.lang.String.format(String , object) and use printf like format.
The format string "%1$15s" will do the job. Where 1$ indicates the argument index, s indicates that the argument is a String 15 represent the minimal width of the String. Putting it all together: "%1$15s". read more
Share this article

0 comments:

Post a Comment

 
Copyright © 2019 techfloaters • All Rights Reserved.
Template Design by Ashok Veer ( veersoft solution)