Bag
from Eclipse Collections, which supplies both mutable and immutable versions.
Create Bags
Before we will proceed with various Bag methods, let observe how to initialize a new Bag
instance within the Eclipse Collections framework. Likewise to other types of collections, there are presented both mutable (modifiable) and immutable (non-modifiable) versions. In general, we can use the Bags
class, which allows utilizing static factory methods to obtain bags:
Bags.immutable.*
callsImmutableBagFactory
to create immutable bags.Bags.mutable.*
callsMutableBagFactory
to create mutable bags.
Both types use the same approaches, that can be separated into the following three categories: