toString(): This method is available in java.util.BitSet class of Java.
Syntax:
String java.util.BitSet.toString()
This method returns a string representation of this bit set. For every index for which this BitSet contains a bit in the set state, the decimal representation of that index is included in the result.
Parameters: NA
Returns: a string representation of this bit set.
Exceptions: NA
Approach
Java
import java.util.BitSet;public class BitSettoString {public static void main(String[] args) {BitSet bitSet = new BitSet(100);bitSet.set(1);bitSet.set(50);bitSet.set(6);bitSet.set(10);System.out.println(bitSet.toString());}}
Output:
{1, 6, 10, 50}
No comments:
Post a Comment