2012-09-17 60 views
0

我試圖將輸出2個空格縮進到右側,是否可以使用.format而不是2個空格來實現?Java格式縮進I/O

System.out.format(" %-15s %7.2f %5.0f %-20s\n", getName(), payPerHour, hours, task.getTask()); 
       ^//2 spaces in front 

回答

1

是啊,這是

System.out.format("%2s%-15s %7.2f %5.0f %-20s\n", " ", getName(), payPerHour, hours, task.getTask());