打印以下部分有哪些更好的方法?我认为它以某种带有标题的表格格式看起来会更好。我想我想将它们调整为固定长度。这是我想格式化以使其看起来更好的代码片段。打印元素是 sql 数据库中的元素。
System.out.println("\nAll records in your table:");
System.out.println("ID# Name GPA Status Mentor Level Thesis Advisor Company"); //table heading...
while (rs.next()) {
String output = " ";
output += rs.getString("studentID") + " "
+ rs.getString("firstName") + " "
+ rs.getString("lastName") + " "
+ rs.getString("gpa") + " "
+ rs.getString("status") + " "
+ rs.getString("mentor") + " "
+ rs.getString("level") + " "
+ rs.getString("thesisTitle") + " "
+ rs.getString("thesisAdvisor") + " "
+ rs.getString("company") + "\n";
System.out.printf("%s", output);
}