Array of ArrayList Java
Posted
by David Bobo
on Stack Overflow
See other posts from Stack Overflow
or by David Bobo
Published on 2010-04-07T01:08:23Z
Indexed on
2010/04/07
1:13 UTC
Read the original article
Hit count: 541
Hi,
I am creating an PriorityQueue with multiple queues. I am using an Array to store the multiple ArrayLists that make up my different PriorityQueues. Here is what I have for my constructor so far:
ArrayList<ProcessRecord> pq;
ArrayList[] arrayQ;
MultiList(){
arrayQ = new ArrayList[9];
pq = new ArrayList<ProcessRecord>();
}
The problem comes when I am trying to get the size of the entire array, that is the sum of the sizes of each ArrayList
in the array.
public int getSize(){
int size = 0;
for(int i = 1; i <=9; i++){
size = size + this.arrayQ[i].size();
}
return size;
}
is not seeming to work. Am I declaring the Array of ArrayList
correctly? I keep getting an error saying that this.arrayQ[i].size()
is not a method. (the .size() being the problem)
Thanks for any help!
David
© Stack Overflow or respective owner