• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Update Collection of Objects

 
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.
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • 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 ]
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!