java中lamda表达式用法
map-> list
Mapmap = new HashMap<>(); List list = new ArrayList<>(); map.forEach((k, v) -> { list.add(v.toString()); });
list->map
@Data
public class TestEntity { private String code; private String name; } Listlist = new ArrayList<>(); Map map = list.stream().collect( Collectors.toMap(item -> ((TestEntity )item).getCode, item -> (TestEntity)item) );