Java tutorial
public class PrintfExamples { public static void main(String[] args) { System.out.printf("String is '%5s'\n", "A"); System.out.printf("String is '%-5s'\n", "A"); System.out.printf("String is '%.5s'\n", "Happy Birthday!"); } } /* String is ' A' String is 'A ' String is 'Happy' */