• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Input data into array list

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So.... why not just create a new list every time?
 
reply
    Bookmark Topic Watch Topic
  • New Topic