Reputation: 2465
Like the title says, I am trying to instantiate an ArrayList
with type of a class that I want to be an array. Probably I did not explain it correctly in technical terms, so let's just look at a pseudo code:
List<TestClass[5]> lTestList = new ArrayList<TestClass[5]>();
Where should I specify the size of the TestClass type array? Apologies if my explanation does not make much sense as I am still learning.
Upvotes: 0
Views: 34
Reputation: 176
List<TestClass[]> lTestList = new ArrayList<TestClass[]>();
You shouldn't specify size of array in generic.
Upvotes: 1
Reputation: 59093
The type of a TestClass
array is TestClass[]
. So you need to use that as your generic parameter.
List<TestClass[]> lTestList = new ArrayList<TestClass[]>();
Then when you add items to your list, you can add arrays of the appropriate size.
lTestList.add(new TestClass[5]);
Upvotes: 2