当我尝试显示格式化的字符串时,我的输出非常混乱。
String heading = String.format("%-15s%30s%15s%n", "Stall name", "Num Guests", "Servings");
txaOut.setText(heading + "------------------------------------------------------------- \n");
for (int i = 0; i < tblstallsList.size(); i++) {
double servings = Math.round(tblstallsList.get(i).getNumofguests()*1.25);
String output = String.format("%-15s%30s%15f%n", tblstallsList.get(i).getStallname(), tblstallsList.get(i).getNumofguests(), servings);
txaOut.append(output);
}
来自tblstallsList的值是字符串,而服务将是double。我没有收到错误,我的字体设置为courier new。
提前谢谢你:)