Let say I have class A
public class A {
private int field1;
private String field2;
...
}
I create new Instance of A, then second Instance of A:
A a1 = new A();
A a2 = new A();
Is there any easy way (reflections or so) to copy fields from a2
to a1
without assigning Instance a2
to a1
(I don't want to change reference of Instance a1
, only values of its fields)? I know I can do it manually in some method, but if there are many fields its kinda not practical.
I was thinking if there is maybe some way over reflections ?
Anyone has some experience with it ?