首页 > 技术文章 > stream的groupby出来的map是有顺序的map

PythonOrg 2021-05-12 20:32 原文

stream分组后的map是有序map

List<RedisInstanceTypeDto> typeDtoList = ModuleHelper.mapAll(redisInstanceTypes,RedisInstanceTypeDto.class);
        Map<Integer,List<RedisInstanceTypeDto>> memoryGBMap = typeDtoList.stream().collect(Collectors.groupingBy(RedisInstanceTypeDto::getMemoryGB, LinkedHashMap::new,Collectors.toList()));

推荐阅读