public class Foo{
private String a;
private int b;
public Foo(Foo foo){
this.a = foo.a;
this.b = foo.b;
}
}
Hi eve
You have only 1 constructor, so in order to create an object of class Foo
, you need to pass to the constructor a Foo
and in order to create that Foo
you will need another Foo
and it will go on and on . The code can make much more sense if for e.g. you will have a default constructor in the class and then you constructor
public Foo(Foo foo){
this.a = foo.a;
this.b = foo.b;
}
will act more like a Copy constructor in