public int getBit(int n) {
        if (n < 0 || n > length - 1) {
            throw new IllegalArgumentException(
              "n must be between 0 and " + (length - 1));
        }

        return ((bits & (1 << n)) >> n);
    }