dynamic casting in java
810787Nov 5 2010 — edited Nov 6 2010Hello everyone....
i am having a problem as follows:
i have a method in my project which is taking a reference of object type...
i want to cast the object to the passing type,bt i dont want to cast explictily inside the method...
can something be done by which the object itself get casted to passing type automatically by determining the runtime of the instance being passesd at runtime?
public void change(Object o)
{
/// i want to cast this object to A type without explicit casting.... can it be done through reflection or some other method?
}
call of the above method from main///
p.s.v.main(String[] args)
{
A a =new A();
a.call(new A());
}
}