我用下面的代碼循環:打印使用TreeMap的一個在Java
public void showTablet() {
for (Map.Entry<String, Tablet> entry : tableMap.entrySet()) {
System.out.println(entry.toString());
}
}
結果是:
MyBrand : A123=Brand: MyBrand, Model no.:A123, Price:3000.0
BrandTwo : T222=Brand: BrandTwo, Model no.:T222, Price:2500.0
我想導致
Brand: MyBrand, Model no.:A123, Price:3000.0
Brand: BrandTwo, Model no.:T222, Price:2500.0
爲什麼是關鍵還打印出來了?
或者只是通過['Map.values()'](http://download.oracle.com/迭代javase/7/docs/api/java/util/Map.html#values())並跳過所有條目。 –