Nic*_*ner 6 java generics autoboxing types
这给了我一个错误:
int[] l = new int[] {0, 2, 192, -1, 3, 9, 2, 2};
int[] l2 = new int[] {9001, 7, 21, 4, -3, 11, 10, 10};
int[] l3 = new int[] {5, 5, 5, 64, 21, 12, 13, 200};
Set<List<Integer>> lists = new HashSet<List<Integer>>();
lists.add(Arrays.asList(l));
Run Code Online (Sandbox Code Playgroud)
Eclipse:
add(List<Integer>)
类型中的方法Set<List<Integer>>
不适用于参数(List<int[]>
)
我以为int
应该被自动装箱了Integer
?
Yis*_*hai 15
虽然int被自动装箱到Integer,但int []不会自动装箱到Integer [].
数组不是盒装的,只是类型本身.
请参阅:如何在Java中将int []转换为List <Integer>?解决方法和潜在的原因.
归档时间: |
|
查看次数: |
1857 次 |
最近记录: |