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