JDK8 String转List<String> 、List<Integer> 及List转String
String auctionBlockIds="45,46,47"; 一、String 转List<String> List<String> auctionBlockId= Arrays.asList(auctionBlockIds.split(",")).stream().map(block -> (block.trim())).collect(Collectors.toList());
或:Arrays.asList(StringUtils.split("1,2,2,3,4,5,6,6", ",")); 二、List<String> 转 String String auctionBlockIds=String.join(",",auctionBlockId); 三、 String 转List<Integer> List<Integer> auctionBlockId= Arrays.stream(auctionBlockIds.split(",")).map(s -> Integer.valueOf(s.trim())).collect(Collectors.toList()); 四、List<Integer> 转 String String requisitionLineIds=list.stream().map(requisitionLine->String.valueOf(requisitionLine.getRequisitionLineId())).collect(Collectors.joining(","));
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】博客园携手 AI 驱动开发工具商 Chat2DB 推出联合终身会员
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步