cannot be converted to List>


错误写法:
List<List<Integer>> resList = new ArrayList<ArrayList<Integer>>();
 
正确写法:
 List<List<Integer>> resList = new ArrayList<>();
 
解释:
 List<List<Integer>> 这种数据结构是类似这样的  [ [Integer , Integer] , [Integer , Integer ,  Integer]],类似: [ [1 , 2 ] , [ 23 , 1 , 34 ] ]
 ArrayList() 里面的数据结构是[object , object , object]
new ArrayList<>() 是泛型写法 它会自动匹配数据类型  object会被匹配为 List<Integer>类型,类似: [ 23 , 1 , 34 ] ;
 


免责声明!

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



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