• 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

Update Collection of Objects

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
In our application, we have an option to update previously selected list,
that means previousList contains some objects which are checked and saved in DB, while updating our application, we need to uncheck some previous objects and check more some other objects.

I can able to retrieve previousList, presentList, and originalList (total number of object). How can we update the previousList of objects with presentList of objets.
I just need simple java logic.
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You want to update the list means:
(I assume you use java collections.)
  • You want to add all items from the newList? If yes, then call addAll() method of the previous list with the new list as the argument.
  • You want to remove all items from previous list and add all items from the newList? If yes, then call clear() on the old list and then addAll() as above.

  • By the way, this is not an advanced question. (CarefullyChooseOneForum)
    [ April 03, 2008: Message edited by: Nitesh Kant ]
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic