I have the following Vector and at runtime I want to pass it an Integer, Character, or Float:
public static Vector<Object> interestingValues = new Vector<Object>();
At the same time I want to get an Integer, Float, or Character from it, so there are two things:
-
Will they retain the specific
Integer/Float/Charactertype in theObjectVector, or they all will be stored in the form ofObject? -
How can I retrieve
Integerobjects from thisVector?
Casting:
In case you have multiple types of objects inside the Vector you could check the type using
instanceof:The third thing you can do to avoid the need ov casting objects to a particular type is using a typed
Vector: