Results 1 to 2 of 2
- 10-02-2011, 11:51 PM #1Member
- Join Date
- Oct 2011
- Rep Power
Problems with an ArrayList declaration.
Hello everyone, i have a problem with an ArrayList.
First of all, can an arrayList contain primitive kind of data such as int or char?
And why it gives this error " '(' or '[' expected " to the following line of code?
private ArrayList<int> numeriEstratti=new ArrayList<int>;
Re: Problems with an ArrayList declaration.
generic types can only be objects not primitives -- so change <int> to <Integer>. You'll also want to include ArrayList's parenthesis when you call its constructor:
private ArrayList<Integer> foo = new ArrayList<Integer>(); // don't forget the parenthesis!
- By zenitis in forum New To JavaReplies: 8Last Post: 05-05-2011, 09:29 PM
- By Vin5253 in forum New To JavaReplies: 1Last Post: 02-07-2011, 04:31 AM
- By moriarty in forum New To JavaReplies: 30Last Post: 03-28-2010, 02:00 AM
- By komo225 in forum New To JavaReplies: 4Last Post: 02-12-2009, 04:14 AM
- By Zuela in forum New To JavaReplies: 1Last Post: 06-16-2008, 11:51 AM