• 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

Storing data from different methods into LinkedList

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic