posted 11 years ago
I am using array list to contain a data.
I want to use it to contain data that behaves like a variable or common array.
What I mean with this is after inputing a data into it, we can remove the content and input a new data into it, but the previous value is still there.
For instance, if I have variable A. I input into it a value of 5. After that I can delete the value, but the 5 value still there.
When I use array list the behaviour is different. After inputing a data into it, and I remove the value because I want to input a new different data, the result is that the existing value is also removed.
If I do not remove it, the new data is appended behind the previous data.
For instance, I have these data: 1, 2, 3, 4, 5, 6, 7, 8, 9
First, I want to input 1, 2, 3 into an array list. then input this array list into another variable.
Next, I input 4, 5, 6 into it.
Last, I input 7, 8, 9.
Up to now, what I have is: 1, 2, 3 in the first array list. 1, 2, 3, 4, 5, 6 in the second, and 1, 2, 3, 4, 5, 6, 7, 8, 9 in the last one.
My question is, how I can save 1, 2, 3 in the first array list; 4, 5, 6 in the second; and 7, 8, 9 in the third?