// sample use of BitSet

import java.util.BitSet;
...

/**
  * list of legal states
  */
public static final String[] possibleStates = {
   "AL","AK","AR","AS","AZ","CA","CM","CO","CT","DC",
   "DE","FL","GA","GU","HI","IA","ID","IL","IN","KS",
   "KY","LA","MA","MD","ME","MI","MN","MO","MS","MT",
   "NC","ND","NE","NH","NJ","NM","NN","NV","NY","OH",
   "OK","OR","PA","PR","RI","SC","SD","TN","TT","TX",
   "UT","VA","VI","VT","WA","WI","WV","WY",
};

private BitSet statesVisited = new BitSet( possibleStates.length );

...

// note that we visited AZ state number 4
statesVisited.set( 4 );

// have we visited CA state number 5?
boolean beenToCalifornia = statsVisited.get( 5 );

// note that we have not visited NY state number 38
statesVisited.clear( 38 );

// reverse whatever we said before about TX state 59
statesVisited.flip( 59 );