Ho questo codice che fino a qui è corretto.
public class Matrice {
private int[][]mat;
public Matrice(int[][]mat){
this.mat = new int [mat.length][mat.length];
for (int i=0; i<mat.length; i++)
for (int j=0; j<mat.length; j++)
this.mat[j]= mat [j];
}
public int valoreIntorno(int i){
int valore;
if(i>=0 && i<=mat.length){
valore= mat+mat[i-1]+mat[i-1][i-1]+mat[i-1]+mat[i+1]+mat[i+1][i+1]+mat[i+1]+mat[i-1][i+1]+mat[i+1][i-1];
}else
valore=-1;
return valore;
}
public int []differenzeIntorni(Matrice m){
if (m.mat.length != this.mat.length)
Ad un certo punto si richiamano le matrice precedentemente definite in queste modo m.mat.length
Perché è così inveche che m.length??