I call a method with the signature save(Object o)
this way:
EntityManager em = new EntityManager(); // My own EntityManager
User user = new User(); // Constructor provides values
em.save(user);
In the save-method I need to instantiate a new object, in this case it would be of type User
this way: User user = (User) o;
Well, so far I can extract the class of the object with o.getClass()
, which delivers class org.example.User
, which is User.class
I guess. But I can't figure out how I could realize the line User user = (User) o;
with that.