随笔分类 - 集合
摘要:第一种方法: List<String> list = Arrays.asList("1", "2", "3", "4", "5"); // method1 创建一个Integer类型的集合,循环遍历String类型的数组并把数据添加进集合 List<Integer> integerList = ne
阅读全文
摘要:List<PPSIIResp> influenceIndexRespList = dataServiceDetailMapper.listPPSIIWithCountrys(null); List<PPSIIResp> subList = ppsiiRespList.stream().skip((P
阅读全文
摘要:1. Collections.swap(list,b,c);(注意:索引为a的元素与索引为b的元素交换位置,其他元素的索引值不变) list是你需要换位置的List。 a是你当前需要换位置的元素的索引。 b是你需要将这个元素换到哪个索引。 2.list.add(0, list.remove(i));
阅读全文
摘要:在Stream流中将List转换为Map,是使用Collectors.toMap方法来进行转换。 1.key和value都是对象中的某个属性值。 Map<String, String> userMap1 = userList.stream().collect(Collectors.toMap(Use
阅读全文
摘要:今天遇到这个问题时,发现有一个工具类可以快速解决这个问题,那就是org.apache.commons.lang3包下的StringUtils工具类下的join()方法。 StringUtils中join()方法的使用,如下示例所示: import java.util.ArrayList; impor
阅读全文
摘要:if(scenicInfo.getKindsImage() != null){ List<String> imageUrl = JSONArray.parseArray(scenicInfo.getKindsImage(),String.class); scenicInfo.setKindsImag
阅读全文