Reputation: 21
I did it as follows, but it wouldn't work:
JComboBox brand = new JComboBox({"Pizza Hut", "Papa John's", "Dominos" });
The error is:
Syntax error on token "new", @ expected after this token
Kindly help me understand what the problem is.
Upvotes: 0
Views: 1358
Reputation: 347184
You can't short cut the creation of the array, you need to provide more information so the compiler can resolve the types, for example
JComboBox brand = new JComboBox(new Object[]{"Pizza Hut", "Papa John's", "Dominos" });
Upvotes: 4