关于LIst<Integer>转String的三种方式

List<Integer> typeKey = pointImageMapper.selectPointByKey(rows.get(i).getPointKey());
Integer[] typeKeyS = new Integer[typeKey.size()];
for (int j = 0; j < typeKey.size(); j++) {
typeKeyS[j] = typeKey.get(j);
}
//第一种比较累
String joins = StringUtils.join(typeKeyS, ",");
//第二种比较简洁
Joiner.on(",").join(typeKey);
//第三种用流的形式,直接将integer转换为String
typeKey.stream().map(String::valueOf).collect( Collectors.joining(","));
posted @ 2022-02-25 11:34  夏之  阅读(3169)  评论(0编辑  收藏  举报