Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Update Collection of Objects

 
Simpson Kumar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • 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.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • 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 ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic