2
我正在練習我的Java技能,我試圖左對齊所有東西,但是,它不能正常工作。左對齊和右對齊襯裏輸出?
基本上,我想是這樣的:
Player: Jackson
Number of tries: 14
,這裏是我嘗試:
String format1 = "%-30s %30s%n";
String temp = String.format(format1, "Player:", "Jackson");
System.out.print(temp);
temp = String.format(format1, "Number of tries:", "14");
System.out.print(temp);
然而,在左側的話不匹配,而右側的詞不匹配。
([?使用的String.format()我怎麼能左對齊字符串]的可能的複製http://stackoverflow.com/questions/4893313/how-可以-I-左對齊弦 - 使用字符串格式) – Barney