public class Foo{ private String a; private int b; public Foo(Foo foo){ this.a = foo.a; this.b = foo.b; } }
Hi eve
There is nothing wrong with your code. Actually what you did has a name: copy constructor And it is very convenient way to make o copy of another object. (assuming you have some other way to create instance of it besides this constructor )