Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static int setBit(int[] bits, int index) throws IndexOutOfBoundsException { if (index < 0 || index > bits.length * 32) throw new IndexOutOfBoundsException("index = " + index); return bits[index >> 5] |= 1 << (index & 0x1F); } }