在你的示例中,这是因为你没有原始类型的列表。换句话说,这
List<int>是不可能的。
但是,你可以
List<Integer>使用Integer包装
int原始类型的类。List使用
Arrays.asList实用程序方法将数组转换为。
Integer[] spam = new Integer[] { 1, 2, 3 };List<Integer> list = Arrays.asList(spam);
在你的示例中,这是因为你没有原始类型的列表。换句话说,这
List<int>是不可能的。
但是,你可以
List<Integer>使用Integer包装
int原始类型的类。List使用
Arrays.asList实用程序方法将数组转换为。
Integer[] spam = new Integer[] { 1, 2, 3 };List<Integer> list = Arrays.asList(spam);