This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Game Development and the fly likes ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "ArrayList" Watch "ArrayList" New topic


Nidhi Kumar

Joined: Jun 30, 2008
Posts: 1
i have to use arraylist to store data throughout my can i prevent arraylist from losing the previous i need to initialize arraylist everytime whenever i call that file??

please give some suggestions.
thanks in advance.
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
I'm not sure what you want to do.Can you, please, elaborate?

Manuel Leiria<br /> <br />--------------<br />Peace cannot be kept by force; it can only be achieved by understanding. <br /> Albert Einstein
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3381

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 ]

Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
Is this topic not better off in the Beginner forum?
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 696
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

Joined: Feb 19, 2008
Posts: 120
Can't you use some different collection objects.....

Or you are restricted to Arraylist
Bert Bates

Joined: Oct 14, 2002
Posts: 8898
This might be better off in another forum but let's leave it here to breathe a little life into this one

Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
I agree. Here's the link:
subject: ArrayList
It's not a secret anymore!