java8操作起来是非常的流畅简单啊,代码如下:

@Data
public class Account {
private String username;
private Integer money;

public Account() {
}
public Account(String username, Integer money) {
this.username = username;
this.money = money;
}

public static void main(String[] args) {
HashMap<String, Integer> map = new HashMap<>();
map.put("mayun",2000);
map.put("mahuateng",1200);
map.put("liuqiangdong",700);
List<Account> collect = map.entrySet().stream().map(en -> new Account(en.getKey(), en.getValue())).collect(Collectors.toList());
collect.stream().forEach(n-> System.out.println(n));
}
}