Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes 2d  Arraylist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "2d  Arraylist" Watch "2d  Arraylist" New topic
Author

2d Arraylist

kalai sundar
Ranch Hand

Joined: May 25, 2005
Posts: 69
My problem is
for(int i=0;i<10;i++)
{
DNewRow.add(i,NewRow);
}

Here NewRow,DNewRow is Arraylist , so for the i'th index, the NewRow arrayList will be stored,like that for every index of the i'th value NewRow will be added to DNewRow.

now i want to reterive that value, c in 2d array we will retrive as follows
for(int i=0;i<arr[].lenght;i++){
for(int j=0;j<arr2[].lenght;j++){
SOP(New2D[i][j]);
}

How i can reteiver for ArrayList, plz hepl me


kalai
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
Hint: The opposite to add is the get method. This takes one parameter - the index of the value you want to retrieve. Which value do you want to retrieve? The ith.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Do you know how to get an element from a "1D" ArrayList? If so, you basically do the same thing twice witha "2d" ArrayList. It sounds like you might need some more help with the Collections Framework in general. You should take a look at the Collections Trail from Sun's Java Tutorial. You should also take the time to become intimately familiar with the API documentation for the version of Java you are using.

After reviewing the links I have given above, please come back with more questions if anything is still unclear.

Layne


Java API Documentation
The Java Tutorial
kalai sundar
Ranch Hand

Joined: May 25, 2005
Posts: 69
i want to reterive i'th value
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
I know, I told you that two posts ago

To retrieve the first value: list.get(0)
To retrieve the second value:list.get(1)
To retrieve the third value: list.get(2)
To retrieve the xth value: list.get(x)
 
Consider Paul's rocket mass heater.
 
subject: 2d Arraylist
 
Similar Threads
ArrayList Compare
ArrayList
going through the [][] array
from a 2d array to a regular array....
Null pointer Exception