0

I want to create an ArrayList of type product

How do I insert an array into the 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?

3
  • Post the declaration of the ItemisedProductLine and ProductLine constructors. in itself your code is fine. Commented May 10, 2012 at 8:48
  • apart from the too many closing Parentheses on the ItemisedProductLine line Commented May 10, 2012 at 8:50
  • 1
    OP, please convince us that you are not abusing us to balance your parens for you. Commented May 10, 2012 at 8:57

1 Answer 1

2

Isn't there an extra ")" at the end of line 7?

Sign up to request clarification or add additional context in comments.

4 Comments

Let's hope he's not alerting SO about ONE EXTRA PAREN!
Hmm, checked. You're right :) I hate those (((( and )))), always confusing me! xD
embarrassing!!! i really need a break. You guys actually right, now it complains about something in my ItemisedProductLine class.
Thanks everyone for the help, i spent quite a bit of time on that(better i don't say how much...):-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.