List<Integer> intList = strList.stream().map(Integer::parseInt).collect(Collectors.toList());
public static void main(String[] args) {
List<String> strList = new ArrayList<String>();
strList.add("1");
strList.add("2");
strList.add("3");
strList.add("4");
strList.add("5");
strList.add("6");
for (String str : strList) {
System.out.println("这是String类型:" + str);
}
System.out.println("+++++++++++++++++++++++++++++++++");
List<Integer> intList = strList.stream().map(Integer::parseInt).collect(Collectors.toList());
for (Integer code : intList) {
System.out.println("这是Integer类型:"+code);
}
方法二:mapToInt
List<Integer> intStream = strList.stream().mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());