Consider the code below:
Project project1 = new Project("string1","string2","string3","string4","string5", ...);
Project project2 = project1;
Here, project2
is not a copy of project1
, because it points to the same object.
It significate that if I edit project2
, it also edit project1
.
I want project2
to be independent of project1
.
I suppose that I can make a constructor with a Project
param like:
public Project(Project project) {
this.string1 = project.getString1();
this.string2 = project.getString2();
...
}
I my case, I have something like 15 attributes in my Project class, so doing this would require me to write a big constructor.
Is there a better way to do this ? :)
Thanks !