Java BitSet isEmpty() method

The isEmpty() method of Java BitSet class returns true if this BitSet does not contain any bits which are set to true.

Syntax:

Parameter:

NA

Returns:

The isEmpty() method returns a Boolean value true or false on the basis of this BitSet is empty or not.

Exception:

NA

Compatibility Version:

Java 1.4 or above

Example 1

Output:

bitset1: {1, 2, 3, 4}
bitset2: {}
bitset1 isEmpty: false
bitset2 isEmpty: true