我試圖通過爲每個列結果選擇一個好的選項卡來使結果看起來不錯。 這是我的toString()函數。我在stackoverflow中搜索這個問題,但它不回答我的問題。我無法在Eclipse Java中找到StringUtils.rightPad(String,int)實用程序。我應該下載任何軟件包或其他東西?如何創建一個在Eclipse中分隔的製表符Java
public String toString(){
StringBuffer sb = new StringBuffer(150);
sb.append(getDept(department));
sb.append("\t");
sb.append(getName());
sb.append("\t");
sb.append(getAge());
sb.append("\t");
sb.append(checks.check());
return sb.toString();
}
Here's my result using ("\t") :
Department Name Age Prime
__________________________________________________
Information_Systems Hacking Novice 23 true
Accounting Counting Novice 25 false
Marketing Sales Savvy 38 false
Information_Systems Hacking Savvy 38 false
Accounting Counting Savvy 40 false
Accounting Counting Pro 45 false
Information_Systems Hacking Pro 46 false
Human_Resources Hiring Pro 47 true
Marketing Sales Pro 48 false
Marketing Sales Guru 50 false
Information_Systems Hacking Guru 51 false
Accounting Counting Guru 55 false
Human_Resources Hiring Guru 58 false
這究竟有Eclipse的呢?你只是在尋找正確填充字符串的方法,是不是。 – Ingo
看看這個答案:http://stackoverflow.com/questions/699878/is-there-an-easy-way-to-output-two-columns-to-the-console-in-java – Julien
它可以工作printf,但不追加。 – Bejibun