/* * BitSets are packed into arrays of "words." Currently a word is a long, which consists of 64 bits, requiring 6 address bits.
* The choice of word size is determined purely by performance concerns.
*/ private final static int ADDRESS_BITS_PER_WORD = 6;
private final static int BITS_PER_WORD = 1 << ADDRESS_BITS_PER_WORD;
private final static int BIT_INDEX_MASK = BITS_PER_WORD - 1;
特性:
1、默认的构造函数声明一个64位的BitSet,超过64的按64的倍数算
0<size<=64 64
64<size<=64*2 64*2
64*2<size<=64*3 64*3
2、值只有true和false,占用空间小按照二进制存储的一个元素为二进制的一位应用:存储数字例如3,5,6,9 四个数字BitSet bs = new BitSet();bs可以设成 [0,0,0,1,0,1,1,0,0,1] 按下标来存储