testEntrySet方法問題
輸出為
取得鍵:1
對應的值為:com.CollectionTest.Student@232204a1
取得鍵:3
對應的值為:com.CollectionTest.Student@4aa298b7
提上代碼
public?void?testEntrySet()?{ //?通過entrySet方法返回Map中所有鍵值對 Set<Entry<String,?Student>>?entryset?=?Students.entrySet(); for?(Entry<String,?Student>?entry?:?entryset)?{ System.out.println("取得鍵:"?+?entry.getKey()); System.out.println("對應的值為:"?+?entry.getValue()); } }
2016-03-27
System.out.println("取得鍵:" + entry.getKey());
這里輸出為啥沒加.ID呢
2015-05-19
哈哈 機智啊 ?如果不加等于輸出對象的地址
2015-05-17
結果我自己發(fā)現(xiàn)了問題。。
第六行改為System.out.println("對應的值為:"?+?entry.getValue().name);