public class Format
{
public static void main(String args[])
{
System.out.printf("%30s|%30s","Organization","Number of users");
System.out.printf("%30s|%30s","Arcot","100");
}
}
它打印:
Organization| Number of users Arcot| 100
为什么第二行未对齐?单词“ Arcot”没有足够的填充,尽管单词“ 100”足够。抱歉,此文本窗口采用了自己的格式,未显示我粘贴为输出的内容。您可能需要运行代码以查看获得的输出。
最佳答案
试试这些。
System.out.println(String.format("%30s|%30s","Organization","Number of users"));
System.out.println(String.format("%30s|%30s","Arcot","100"));