Results 1 to 2 of 2
- 10-02-2011, 11:51 PM #1
Member
- Join Date
- Oct 2011
- Posts
- 1
- Rep Power
- 0
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?
Java 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:
Java Code:private ArrayList<Integer> foo = new ArrayList<Integer>(); // don't forget the parenthesis!
Similar Threads
-
Having problems clearing an arrayList
By zenitis in forum New To JavaReplies: 8Last Post: 05-05-2011, 09:29 PM -
How to implement boolen in this arraylist problems?
By Vin5253 in forum New To JavaReplies: 1Last Post: 02-07-2011, 04:31 AM -
Problems with a loop calling data from an ArrayList.
By moriarty in forum New To JavaReplies: 30Last Post: 03-28-2010, 02:00 AM -
ArrayList problems
By komo225 in forum New To JavaReplies: 4Last Post: 02-12-2009, 04:14 AM -
[Problems] ArrayList
By Zuela in forum New To JavaReplies: 1Last Post: 06-16-2008, 11:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks