BitSet bitSet1 = new BitSet(4); bitSet1.set(0); bitSet1.set(2); bitSet1.set(3); BitSet bitSet2 = new BitSet(4); bitSet2.set(0); bitSet2.set(1); bitSet2.set(2); bitSet1.andNot(bitSet2); System.out.println(bitSet1); // prints "{2, 3}"In this example, we create two BitSets with 4 bits each. We set some bits in both BitSets and then perform a logical "and not" operation on bitSet1 with bitSet2. The resulting BitSet contains only the bits that are set in bitSet1 but not in bitSet2, which are the bits at positions 2 and 3. The package library for java.util BitSet is "java.util".