[英]how to assign a value to a list in java if i assign a following value it shows cannot convert from int[] to List<Integer>
How to assign a value to a list in java?如何在java中为列表赋值? If Ii assign a following value it shows cannot convert from int[] to List<Integer>
如果 Ii 分配以下值,则显示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};
}
您可以使用 Arrays.asList 创建列表
ArrayList<Integer> newObj = new ArrayList(Arrays.asList(new Integer[]{1,2,3}));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.