• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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 ]
     
    no wonder he is so sad, he hasn't seen this tiny ad:
    the value of filler advertising in 2021
    https://coderanch.com/t/730886/filler-advertising
    reply
      Bookmark Topic Watch Topic
    • New Topic