Hello I have a class called Ladrillo and in another class I have a 2d array type Ladrillo. I want to clone that array so that if the original one changes this one doesnt.
From what I read online in my ladrillo class I have to put Implements clonable. I did that and the following code but it didn't work:
Ladrillo [][] copy=new Ladrillo[original.length][original.length];
for(int i=0;i<original.length;i++){
for(int j=0;j<original.length;j++){
Ladrillo newLadrillo=original[i][j].clone();
copy[i][j]=newLadrillo;
}}
Any ideas on what to change? I believe I have to add something on the class Ladrillo but I haven't figured it out. Thanks!