Change the object instance type : Type Casting « Type Casting « SCJP






import java.util.Vector;

class MyClass {
}

public class MainClass {
  public static void main(String[] argv) {
    Vector v = new Vector();
    v.add(new MyClass());

    MyClass a = (MyClass) v.elementAt(0);
  }
}








4.1.Type Casting
4.1.1.You can explicitly change the type of a value by casting.
4.1.2.Change the object instance type
4.1.3.A widening conversion is a conversion from a smaller numeric type to a larger numeric type.
4.1.4.A narrowing conversion is a conversion from a larger numeric type to a smaller numeric type.