如何使java中的输出语句对齐啊???高手请进!急急急!悬赏5点财富,财富真的不多了,望谅解!

比如说:
周** 24 13
方** 25415 546458
廖** 145 54456654
即从开始每一列都要对齐!!!
public class StudentInformation
{
public static void main (String[] args)

{ System.out.println ("name hometown major");
System.out.println("==== ===== =====");
System.out.println("Sally Roanoke Computer Science");
System.out.println("Alexander Washinggton Math") ;
System.out.println("Student 1 Sometown Some Major");
System.out.println("Name 2 Another Town A Major");
System.out.println("Name3 somewhere Some Major");
}
}这是我编写的代码,但是输不出那种效果
!!!!

你在输出的时候加上\t试试
System.out.println("name\t\thometown\tmajor");
System.out.println("====\t\t=====\t\t=====");
System.out.println("Sally\t\tRoanoke\t\tComputer Science");
System.out.println("Alexander\tWashinggton\tMath");
System.out.println("Student 1\tSometown\tSome Major");
System.out.println("Name 2\t\tAnother Town\tA Major");
System.out.println("Name3\t\tsomewhere\tSome Major");
温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜