访问量: 34118次,访客数: 29179人,浏览量: 1次 
首页  编辑  

List转Map

Tags: /Java/   Date Created: Tue Oct 29 2024 03:23:31 GMT+0000 (Coordinated Universal Time)
Java中,把List<Demo>对象中根据某个key转换为 Map<key, Demo> 列表
Map<Long, Demo> map = list.stream().collect(Collectors.toMap(Demo::getKey, item -> item))