public class PrintF { public static void main(String[] args) { System.out.println("1234567890123456789012345"); // Right-aligned string using 5 places System.out.printf("%5s", "cat"); // Right-aligned decimal using 7 places and zero-filled on the right System.out.printf("%n%7.2f", 5.3); // Dollar sign followed by right-aligned decimal using 8 places and rounded System.out.printf("%n$%8.1f", 44.756); // Right-aligned integer using 5 places System.out.printf("%n%5d%n", 12); // Percent symbol followed by right-aligned integer using 11 places System.out.printf("%%%11d", 6382538); // Right-aligned decimal zero-filled on the right System.out.printf("%n%f%n", -505.14); // Right-aligned integer zero-filled on the left System.out.printf("%07d", -42); // Left-aligned integer followed by right-aligned decimal System.out.printf("%n%-5d %6.1f", 25, 9.7); // Right-aligned integer followed by left-aligned decimal System.out.printf("%n%5d %-6.1f", 25, 9.7); } }