This week's book giveaway is in the JavaScript forum. We're giving away four copies of Meteor in Action and have Stephan Hochhaus & Manuel Schoebel on-line! See this thread for details.

It represents binary bits (if you don't know what a bit is, check this). For example, imagine that you have the following byte : 00001100 (=12 in decimal). You can represent it like this :

The ouput is {2, 3}, which tells you that bits 2 and 3 are on.

Imagine that you have another byte 00001000, and you want to "and" its value with the first byte. The BitSet class allows you to do the basic logical functions "and", "or", "xor".

The output is now {3}, because bit 2 was turned off during the "and" operation.

(I don't remember having used this class ever before)

Bits are obviously numbered from right to left, starting at 0, so the least significant bit in that example is no 0 and the most significant bit is no 7.