提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
右对齐字段中的整数。
public class Main //NowJava.com - 时代Java 提 供 { public static void main(String[] args) { System.out.printf("%4d\n", 1); System.out.printf("%4d\n", 12); System.out.printf("%4d\n", 123); System.out.printf("%4d\n", 1234); System.out.printf("%4d\n\n", 12345); // data too large System.out.printf("%4d\n", -1); System.out.printf("%4d\n", -12); System.out.printf("%4d\n", -123); System.out.printf("%4d\n", -1234); // data too large