Java tutorial
//package com.java2s; import java.util.BitSet; public class Main { public static BitSet bitSetOf(int... values) { BitSet bitSet = new BitSet(values[values.length - 1] + 1); for (int value : values) { bitSet.set(value); } return bitSet; } }