You should use the new Generics features from Java 5.
When you take an element out of a
Collection, you must cast it to the
type of element that is stored in the
collection. Besides being
inconvenient, this is unsafe. The
compiler does not check that your cast
is the same as the collection's type,
so the cast can fail at run time.
Generics provides a way for you to
communicate the type of a collection
to the compiler, so that it can be
checked. Once the compiler knows the
element type of the collection, the
compiler can check that you have used
the collection consistently and can
insert the correct casts on values
being taken out of the collection.
You can read this quick howto or this more complete tutorial.