Here you can find the source of increment(BitSet bits, int size)
public static boolean increment(BitSet bits, int size)
//package com.java2s; //License from project: Open Source License import java.util.BitSet; public class Main { public static boolean increment(BitSet bits, int size) { int i = size - 1; while (i >= 0 && bits.get(i)) { bits.set(i--, false);/*from w w w . j a v a 2s .c o m*/ } if (i < 0) { return false; } bits.set(i, true); return true; } }