T
Taria
Hello all,
Yes, it's me again and ArrayLists. <grins> I'm having trouble
referencing the individual element of an ArrayList within an ArrayList
so that I can initialize another ArrayList in a single ArrayList way.
Let ArrayList A = a series of Arraylists where
0th element = {1,3,4,2}
1st element = {4,4,2}
2nd element ={1,7,2}
etc
What I hope B arraylist will look like:
B is a simple ArrayList
0th element = 1
1st element = 3
2nd element = 4 and so on.
So to reference the number 1 in the the A arraylist would be:
System.out.println ("ArrayList A(0,0) = " +
(ArrayList).get(0).get(0));
and to reference the number 1 in the B arraylist would be:
System.out.println ("ArrayList B(0) = " + Arraylist.get(0));
Now, what I want to do is, give ArrayList B the values of the 0th row
Arraylist 1,3,4,2 where ArrayList B (0)=1, ArrayList(1) =3 and so on.
I have tried this:
for ( int i = 0; i < A.get(0).size(); i++ ) {
node.add((ArrayList) data.get(0).get(i));
}
At the node.add I'm getting a 'symbol not found' error. So is this
because the add method doesn't support the reference type I'm passing?
It's late and I'm too tired to create a short SSCE to show this in a
program. I hope this is enough to convey what I'm trying to do and
the error I'm receiving. I'll try to create a short version between
work and school tomorrow.
As always, your comments and hints are appreciated.
-t (feeling a little perturbed at ArrayLists)
Yes, it's me again and ArrayLists. <grins> I'm having trouble
referencing the individual element of an ArrayList within an ArrayList
so that I can initialize another ArrayList in a single ArrayList way.
Let ArrayList A = a series of Arraylists where
0th element = {1,3,4,2}
1st element = {4,4,2}
2nd element ={1,7,2}
etc
What I hope B arraylist will look like:
B is a simple ArrayList
0th element = 1
1st element = 3
2nd element = 4 and so on.
So to reference the number 1 in the the A arraylist would be:
System.out.println ("ArrayList A(0,0) = " +
(ArrayList).get(0).get(0));
and to reference the number 1 in the B arraylist would be:
System.out.println ("ArrayList B(0) = " + Arraylist.get(0));
Now, what I want to do is, give ArrayList B the values of the 0th row
Arraylist 1,3,4,2 where ArrayList B (0)=1, ArrayList(1) =3 and so on.
I have tried this:
for ( int i = 0; i < A.get(0).size(); i++ ) {
node.add((ArrayList) data.get(0).get(i));
}
At the node.add I'm getting a 'symbol not found' error. So is this
because the add method doesn't support the reference type I'm passing?
It's late and I'm too tired to create a short SSCE to show this in a
program. I hope this is enough to convey what I'm trying to do and
the error I'm receiving. I'll try to create a short version between
work and school tomorrow.
As always, your comments and hints are appreciated.
-t (feeling a little perturbed at ArrayLists)