P
Phillip Lord
HalcyonWild> Apart from collections, is there any other place we can
HalcyonWild> think of using Generics.
Anything with a data model. Swing is an obvious example--instead of
ListModel, you will use DefaultListModel, and the contents of the
ListModel will be generic'd.
HalcyonWild> Plus you wont use generics if you are keeping instances
HalcyonWild> of different objects in a Vector,
HalcyonWild> eg. (String)vec.elementAt(0); and
HalcyonWild> (Hashtable)vec.elementAt(1);
In almost all cases, this is a bad idea anyway. If you do this, you
are either going to dispatch the object returned based on it's class
(which is okay, but not normally necessary), or you are using
implicit structuring in an vector (first element is a name, second a
phone number perhaps). In which case you should be using an object.
Phil
HalcyonWild> think of using Generics.
Anything with a data model. Swing is an obvious example--instead of
ListModel, you will use DefaultListModel, and the contents of the
ListModel will be generic'd.
HalcyonWild> Plus you wont use generics if you are keeping instances
HalcyonWild> of different objects in a Vector,
HalcyonWild> eg. (String)vec.elementAt(0); and
HalcyonWild> (Hashtable)vec.elementAt(1);
In almost all cases, this is a bad idea anyway. If you do this, you
are either going to dispatch the object returned based on it's class
(which is okay, but not normally necessary), or you are using
implicit structuring in an vector (first element is a name, second a
phone number perhaps). In which case you should be using an object.
Phil