Java BitSet toString() method

The toString() method of Java BitSet class returns a string representation of this bit set. The indexes of set bit are returned from lower index to higher index. These set bit are separated by a comma and space ", " surrounded by curly braces.

Syntax:

Parameter:

NA

Returns:

This method returns the string representation of this bit set.

Exception:

NA

Compatibility Version:

Java 1.0 and above

Example 1

Output:

empty bitset: {}
bitset: {0}
bitset: {0, 3}
bitset: {0, 2, 3, 4}