• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayList

 
Nidhi Kumar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i have to use arraylist to store data throughout my application.how can i prevent arraylist from losing the previous data.do i need to initialize arraylist everytime whenever i call that file??

please give some suggestions.
thanks in advance.
 
Manuel Leiria
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you want to do.Can you, please, elaborate?
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Nidhi kumar,

Welcome to JavaRanch. ArrayList is yet another object and it does NOT lose its contents until and unless its elements are cleared off by calling the clear() method on the arraylist object .

What exactly are you dealing with ? Can you paste some sample code or tell us more about what exactly you are doing?
[ July 01, 2008: Message edited by: Raghavan Muthu ]
 
Gavin Tranter
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this topic not better off in the Beginner forum?
 
Norm Radder
Bartender
Posts: 1241
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To save data across invocations of your program you'll need to write the contents to a disk file at the end of the program and then read that file when you start the program.
 
Rakesh Chaudhary
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't you use some different collection objects.....

Or you are restricted to Arraylist
 
Bert Bates
author
Sheriff
Posts: 8900
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This might be better off in another forum but let's leave it here to breathe a little life into this one
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic