• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding Bag collection object  RSS feed

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi....
I have doubt on Bag collection object.on which scenario Bag collection object will use?and what is difference between Bag and List ?
 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A "bag" is not a standard collection of core Java, so, you should specify which Bag class you are refering to.

Henry
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raj,

Henry said true, in Java isn't a BAG implementation.
But Bag is a collection of disorder that allows duplicate elements and Hibernate provides a mechanism for a List in Java to simulate the behavior of a Bag.

Hibernate Bag:
https://www.hibernate.org/hib_docs/v3/api/org/hibernate/mapping/Bag.html

Difference between List is:

"An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list."- http://java.sun.com/j2se/1.4.2/docs/api/java/util/List.html

Hope this help you

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!