如何转换printf至print?

时间:2013-12-11 21:26:05

标签: java printf

如何在Java中将System.out.printf("%3s", "");转换为.print()?而且

System.out.printf("%3d\n", (i - startDay));

1 个答案:

答案 0 :(得分:6)

使用String.format(String format, Object... args)

System.out.print(String.format("%3s", ""));

int i = 50;
int startDay = 20;
System.out.print(String.format("%3d\n", (i - startDay)));