Set<String> t=m.keySet(); for(String str:t) { stu=(Student)m.get(str); System.out.println(stu.name); }