• List 转 map ,key 类型转换


    用 stream 流 

    stream.collect(Collectors.toMap() 先转换 map

    然后 

    .entrySet().stream() 在遍历map 更改 key 的类型

    我这里 由Long 转成 string.

    channelTypeMap = rsocialchannelService.findAll()
                    .stream().collect(Collectors.toMap(Rsocialchannel::getSchId, Rsocialchannel::getSchName, (value1, value2) -> value2))
                    .entrySet().stream().collect(Collectors.toMap(e -> String.valueOf(e.getKey()), Map.Entry::getValue));
  • 相关阅读:
    053364
    053363
    oracle导出批量表N行记录
    053362
    053361
    053360
    053359
    053358
    053357
    053356
  • 原文地址:https://www.cnblogs.com/zq1003/p/16418670.html
Copyright © 2020-2023  润新知