如何在java中为列表赋值如果我赋值了下面的值,它显示不能从int[]转换为list< integer>

wlsrxk51  于 2021-07-05  发布在  Java
关注(0)|答案(1)|浏览(327)

如何在java中给列表赋值?如果我指定一个值,它会显示 cannot convert from int[] to List<Integer> ```
public class GetAddonProductsProcessorTest {

@Test
public void AddonProductstest() throws Exception{

//BasicDBList newobj = new BasicDBList();

List<Integer> newobj = {1,2,3};

}

lkaoscv7

lkaoscv71#

可以使用arrays.aslist创建列表

ArrayList<Integer> newObj = new ArrayList(Arrays.asList(new Integer[]{1,2,3}));

相关问题