A BitSet is a set of non-negative integers depicted as arrays. These arrays are variable in size and packed into 64-bit words. The largest number in a BitSet determines its memory footprint.
Let’s take an example:
scala> import scala.collection.immutable._
scala> var nums=BitSet(7,2,4,3,1)
nums: scala.collection.immutable.BitSet = BitSet(1, 2, 3, 4, 7)