其他分享
首页 > 其他分享> > List<String>转List<Integer>

List<String>转List<Integer>

作者:互联网


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);
}

标签:String,List,System,add,strList,out
来源: https://www.cnblogs.com/silloutte/p/15117231.html