code: public boolean getAndSet(int index)
      {
          int wordNum = index >> 6; // div 64
          int bit = index & 0x3f; // mod 64
          long bitmask = 1L << bit;
          boolean val = (bits[wordNum] & bitmask) != 0;
          bits[wordNum] |= bitmask;
          return val;
      }
docs: Sets a bit and returns the previous value. The index should be less than the BitSet
  size.
  
  @param index the index to set
  @return previous state of the index