2Dimensional Array List : Getting Mad !!

Hi,

First of all, I'm an ametuer programmer. Recently, a situation arised for which I had to use a 2dimensional arraylist in my program. But, I had a silly problem which kept me stuck (and is still keeping me stuck) for a while.

The scenario: I want to insert two 1Dimensional arraylists into a 2Dimensional arraylist.

Re: 2Dimensional Array List : Getting Mad !!

The error because both element you are adding to the data_list_2D variable are in fact referring to the same object of data_list_1D. If you change the value of data_list_1D it will reflect in both element of the data_list_2D. To avoid this you should create a new ArrayList before adding it to the data_list_2D.