Check out example codes for "java printf trailing whitespace". It will help you in understanding the concepts better.

Code Example 1

System.out.printf("%-20s", str);

Learn ReactJs, React Native from akashmittal.com