0

I have a 2D array like ...

ArrayList<ArrayList<MParsingClass>> 2d_arraylist = new ArrayList<ArrayList<MParsingClass>>();

I want to get all the Value of the internal Object class like the value of position ...

2d_arraylist [0][1] and gradually so on..... 

Any Help Please ??

3 Answers 3

2

That would work if you were dealing with nested arrays, but you are dealing with nested ArrayLists you have to use ArrayList class methods to access its data, namely the get() method.

You need to use:

2d_arraylist.get(0).get(1);

get(0) gets the first row from your array of arrays (an ArrayList)

get(1) gets the second column from the row you have selected (an MParsingClass)

Sign up to request clarification or add additional context in comments.

Comments

0

You Have to make a 2 for loop like this ...

for(int i=o ; i< size of 2d array ;i++)

// here you have to make another ArrayList which will get the positon of the "i th" //array of your 2D array..

ArrayList<MParsingClass> new_array_list = 2d_arraylist .get(position);

for(int j=o ; i<size of  new_array_list ;i++)

new_array_list.get(your get value)


{

}

Comments

0

This should work:

for(i=0; i<2d_arraylist.size(); i++) {
    ArrayList<MParsingClass> temp = 2d_arraylist.get(i);
    for(j=0; j<temp.size(); j++) {
        MParsingClass obj = temp.get(j);
        //To-Do .....
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.