user1322978 user1322978 - 1 year ago 66
Java Question

printing elements of array in arraylist in java

I do have this code, and I would like to print out all the array's values of Arraylist.
thanks for your help in advanced.

here is my code:

for (int i = 0; i <count; i++) {
System.out.println("list #" + i);
for (int j = 0; j < list[i].size(); j++) {

System.out.println("elements of array in arraylist "+list[i].get(j));


Answer Source

For printing elements of an array stored in arraylist,you will have to to do the following:

for each element of arraylist
 get array from arraylist
   for each array element in array
       print array element.

You seemed to be iterating array of List type instead.

Edit your code with further detail on your data structure

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download