前面做LeetCode上的题目,发现这样的错误
incompatible types: ArrayList<ArrayList> cannot be converted to List<List>
error: incompatible types: ArrayList<ArrayList<Integer>> cannot be converted to List<List<Integer>>
return res;
类型不匹配,查询了一些文档发现是泛型的原因
下面是相关的文档
Generics, Inheritance, and Subtypes
众所周知,只要类型兼容,就可以将一种类型的对象分配给另一种类型的对象。
//例如,你可以指定一个Integer到一个Object,因为Object是Integer的超类型
Object someObject = new Object();
Integer someInteger = new Integer(10);
someObject = someInteger; // OK
//Integer和Double都是Number的一种
public