private Map<String, User> userList = new HashMap<String, User>();
对userList进行了初始化
userList.put("1", new User("1","yonghu1","121","1@qq.com"));
userList.put("2", new User("2","yonghu2","122","2@qq.com"));
userList.put("3", new User("3","yonghu3","123","3@qq.com"));
然后下面这些代码什么意思
Iterator<Map.Entry<String, User>> iterator = userList.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, User> entry = iterator.next();
System.out.println(entry.getKey() + " " + entry.getValue().getUsername());
}
大咪
相关分类