I want to create an ArrayList of type product
我想创建一个类型为product的ArrayList
How do I insert an array into the ArrayList?
如何将数组插入ArrayList?
public Inventory()
{
products = new ArrayList<ProductLine>();
products.add(new ProductLine("A0001", 10.90, 9.90, 100, "N/A"));
products.add(new ProductLine("B0010", 12.00, 7.50, 125, "5"));
products.add(new ProductLine("C0100", 3.00, 2.30, 1000, "16"));
products.add(new ItemisedProductLine("D1000", 2600, 2490, 2, Arrays.asList("a b d", "e f g h", "i j k l"))));
products.add(new ProductLine("E0001", 699, 509, 3, Arrays.asList(new serialNumbers("CCCC333333"),new serialNumbers("DDDD444444"), new serialNumber("AAAA222222"))));
}
I get an error:
我收到一个错误:
"missing ';'
expecting ')'...")
What is the proper way to hardcode an array into an ArrayList?
将数组硬编码到ArrayList的正确方法是什么?
1 个解决方案
#1
2
Isn't there an extra ")" at the end of line 7?
在第7行的末尾是不是有额外的“)”?
#1
2
Isn't there an extra ")" at the end of line 7?
在第7行的末尾是不是有额外的“)”?