Note that Bag includes the following note which is absent from MultiSet: > This interface violates the Collection contract. The behavior specified in many of these methods is not the same as the behavior specified by Collection. The non-compliant methods are clearly marked with "(Violation)". Exercise caution when using a bag as a Collection.
The JavaDoc also indicates that Bag was added in 2.0 while MultiSet is since 4.1. My guess is that MultiSet is an attempt to fix these violations. Peter On Sat, Jul 4, 2026 at 2:03 PM Gary Gregory <[email protected]> wrote: > On Sat, Jul 4, 2026 at 9:36 AM Elliotte Rusty Harold <[email protected]> > wrote: > > > > There's no good reason I can see to have both. Multiset and bag are > > different names for the same thing. > > > > Now if you're asking why this mistake was made in the first place, I > > can speculate and the commit history might have some clues. > > The first commit for both interfaces is from Thomas Neidhart so maybe > he can clarify. > > Gary > > > > > On Thu, Jul 2, 2026 at 9:42 PM Gary Gregory <[email protected]> > wrote: > > > > > > Hi All, > > > > > > Why do we have both Bag and MultiSet? They seem to do the same thing. > > > > > > Gary > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [email protected] > > > For additional commands, e-mail: [email protected] > > > > > > > > > -- > > Elliotte Rusty Harold > > [email protected] > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
