Java Collection Tutorial - Java BitSet.valueOf(byte[] bytes)


BitSet.valueOf(byte[] bytes) has the following syntax.

public static BitSet valueOf(byte[] bytes)


In the following code shows how to use BitSet.valueOf(byte[] bytes) method.

import java.util.BitSet;
//  w  w w  .java 2s. c  o m
public class Main {

   public static void main(String[] args) {

      BitSet bitset1 = BitSet.valueOf(new byte[]{1,2,3});

      // print the sets
      System.out.println("Bitset1:" + bitset1);


The code above generates the following result.