BitSet.valueOf(byte[]): This method is available in java.util.BitSet class of Java.
Syntax:
BitSet java.util.BitSet.valueOf(byte[] bytes)
This method takes one argument of type byte array as its parameter. This method returns a new bit set containing all the bits in the given byte array.
Parameters: One parameter is required for this method.
bytes: a byte array containing a little-endian representation of a sequence of bits to be used as the initial bits of the new bit set.
Returns: a BitSet containing all the bits in the byte array.
Exceptions: NA
Approach
Java
import java.util.BitSet;public class BitSetvalueOfbyte {public static void main(String[] args) {byte bytes[] = { 1, 3, 4, 10 };System.out.println(BitSet.valueOf(bytes));}}
Output:
{0, 8, 9, 18, 25, 27}
No comments:
Post a Comment