BitSet valueOf does what?

Viewed 1447

I'm having an extremely difficult time understand BitSet.valueOf(bytearray)

I have the following code:

byte[] a = new byte[]{(byte) 0x2D, (byte) 0x04};
//binary => 0010 1101 0000 0100
BitSet bs = BitSet.valueOf(a);
System.out.println(bs);

Code above gives me an output of {0, 2, 3, 5, 10}. Why?

I thought it was supposed to return the indices that are true, or holds 1, backwards which then should be {2, 8, 10, 11, 13}.

2 Answers
Related