代码我都看过了没问题啊
testEntrySet应该这样写
你少了一行代码foreach循环
public void testEntrySet() { Set<Entry<String,Student>>entrySet=students.entrySet(); for (Entry<String, Student> entry : entrySet) { System.out.println("取得键值"+entry.getKey()); System.out.println("对应的值为:"+entry.getValue().id); } }