File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Storing data from different methods into LinkedList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Storing data from different methods into LinkedList" Watch "Storing data from different methods into LinkedList" New topic
Author

Storing data from different methods into LinkedList

Laura Balsamo
Greenhorn

Joined: Oct 16, 2011
Posts: 3
Hello all,

Thank you in advance for the assistance. I have a code that I must edit. Currently it features a LinkedList structure with multiple methods throughout various classes adding data into this LinkedList and then printed at the end. I am tasked with changing this so, instead of these methods adding data to the LinkedList throughout the program, it only adds the data at the end (in a separate test class). My trouble is that this structure makes perfect sense to me so I don't know where to start. How do I get data from different methods into this LinkedList without continuously appending it as the methods are executed?

Thanks.
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
The only thing I can think of seems too obvious to be the answer, but you haven't given a lot of details about why someone wants you to do this. It is possible they didn't give you many details either.

If for some reason they want a linked list that gets all its additions "all at once", and the various additions all come from different methods, then all I can think of is to accumulate them in a different linked list, and then transfer them from one to the other "all at once".

I suppose if someone wanted to lock the linked list from alterations before the first addition until after the last one, but didn't want to lock for execution of all the methods, then it might make sense to do this. But it's just a shot in the dark.

rc
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363
    
  23
And welcome to the Ranch
 
 
subject: Storing data from different methods into LinkedList