Java中的Lambda表达式[listToMap]

List < Entity> 转 Map<Entity.getId,Entity>

Map<Long, VipEntity> vipMap = vipList.stream().collect(Collectors.toMap
(VipEntity::getUserId, v -> v, (v1, v2) -> v1));

分别代表的含义

1. vipList.stream().collect(Collectors.toMap(....)) : stream()方法里的将list转换为map的方法
2.VipEntity::getUserId : 将每一个VipEntity里的UserId作为map的key
3.v->v : 将原来list里的每一个VipEntity作为map里的value
4.(v1,v2)-> v1 因为map里的key不可以重复,这个是如果发生了键重复,使用第一个作为键,后面的自动舍去,(v1,v2)->v2 则相反。