首先我們知道BitSet.cardinary()是判斷bitset中有一個設置爲1的數量。但是如果我們想知道到底是那幾個被設置爲1了該怎麼做?
// 從0開始往後依次尋找
for(int i =0 ; i< bitset.cardinary();i++){
//找到上面的i出現的位置
//This method in BitSet Class is used to return the index of the first bit
//that is set to true, that occurs on or after the specified starting index
System.out.println(BitSet.nextBit(i));
}