How to cast an object to a variable class with java?

Zach

New member
I have an object that needs to be cast into whatever the variable being taken in is.
I will show example code that reflects what I would like to work, but is non-compilable:

Object a = new Object();
Object b = new Object();
b = (a.getClass()) b;

or perhaps written as:

Object a = new Object();
Object b = new Object();
Class c = a.getClass();
b = (c) b;

none of these will actually work.
Any ideas of how to implement this?
 
Back
Top