플랜트 배열 목록에 대한 딥 복사본을 만들려고 할 때 어떤 이유로 든 null 포인터 예외가 발생하며 그 이유를 알 수 없습니다.<Fish> arrayList 딥 복사
/**
* Copy Constructor. Since landscape is immutable in the scope of our
* project, you could do a simple reference copy for it. However, Fish and
* Plants are mutable, so those lists must be copied with a DEEP copy! (In
* other words, each fish and each plant must be copied.)
*/
private ArrayList<Fish> fish;
private ArrayList<Plant> plants;
private int[][] landscape;
public Model(Model other) {
this.landscape = other.landscape;
for(Fish fishy: other.fish){
this.fish.add(new Fish(fishy));
}
for(Plant planty: other.plants){
this.plants.add(new Plant(planty));
}
}
생성자를 붙여 넣을 수 있습니까? –