java8 字符串转换 list long Integer


1   
2 String ids= "1,2,3,4,5,6";  
3 List<Long> listIds = Arrays.asList(ids.split(",")).stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());  
4 System.out.println(Arrays.toString(listIds .toArray()));//[1,2,3,3,4,5,6]  

//You can use the Lambda functions of Java 8 to achieve this without looping
//来自:http://stackoverflow.com/questions/19946980/convert-string-to-listlong


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM