Suppose I have A mutable class called Person
.
What I want to do is to initialize several variables of Person
at once.
Trying using
Person a,b,c,d;
a=b=c=d=new Person();
would necessarily point all of them to a same memory location. How can I initialize them at once? I don't want to use array or ArrayList.