In the newer versions of
Java List and Set are available and implement the new and improved Collections Interface.
Also HashTable and Map are available.
This is an excerpt from:
http://developer.java.sun.com/developer/Books/MasteringJava/Ch17/index.html#Vectors Vectors, Stacks, and Enumeration The historic collection classes have existed since the beginning of Java's time. While there is nothing technically wrong with them, their usage should be limited to the maintenance of Java 1.0 and 1.1 programs. The primary, historic collection classes that provide ordered access are Vector and Stack. The interface Enumeration offers the means to step through the contents.
Bit Sets Class BitSet implements a set of bits or a vector of boolean values. Unlike many of the other bit set classes or language features in other languages, this bit set has no limits. You can therefore go way beyond the typical 32- or 256-bit limits imposed by other implementations. First, let's look at the class definition:
public class BitSet
implements Cloneable, Serializable {
public BitSet();
public BitSet(int nbits);
public void and(BitSet set);
public void andNot(BitSet set);
public void clear(int bitIndex);
public Object clone();
public boolean equals(Object obj);
public boolean get(int bitIndex);
public int hashCode();
public int length();
public void or(BitSet set);
public void set(int bitIndex);
public int size();
public
String toString ();
public void xor(BitSet set);
}
BitSet operations include the following:
Setting, clearing, and getting single bits
Anding, and notting, oring, and xoring bit sets together
Comparing bit sets
The following program demonstrates their usage, by placing in a BitSet whether or not a planet has an even number of moons. Normally, you would store much larger groups of bits in a BitSet to truly save space:
import java.util.*;
public class TwoBitPlanets {
public static void main (String args[]) {
String names[] = {"Mercury", "Venus", "Earth",
"Mars", "Jupiter", "Saturn", "Uranus",
"Neptune", "Pluto"};
int moons[] = {0, 0, 1, 2, 16, 18, 17, 8, 1};
int namesLen = names.length;
BitSet bits = new BitSet(namesLen);
for (int i=0; i < namesLen; i++) {
if ((moons[i] % 2) == 0) {
bits.set (i);
}
}
for (int i=0; i < namesLen; i++) {
System.out.println (
names[i] + " Even # Moons? " + bits.get(i));
}
}
}
--------------------------------------------------------------------------------
NOTE:
Although BitSet is part of the historical collection classes, the new Collections framework has no replacement. Also, the size() method of BitSet returns the size of the internal structure used, not necessarily the maximum bit number utilized. Since the bit values are stored with the help of a double, size() jumps up by 64 when necessary. More frequently you want the length() method, which returns the highest set bit position.