如图,不太懂为什么,求解答
for (Entry<String, ProductBase> entry : orderList.entrySet()) {
System.out.println(String.format("%15s", entry.getValue().productName)
+String.format("%10s", "$"+entry.getValue().productPrice)
+String.format("%10s", entry.getValue().orderAmount)
+String.format("%10s","$"+(double)entry.getValue().orderAmount*(double)entry.getValue().productPrice)
+String.format("%30s", entry.getValue().getSellTime()));
}
加个Tab键
每行的第一个值长短不一导致的
因为商品名长度不一致啊
用 System.out.printf() 试试