Dos matrices 2x3 entera y determinar si sus contenidos son exactamente iguales. He usado el if sin equals ejemplo (matriz[i][j] == matriz2[i][j]) y esta última con el Arrays.equals y ni así logro que dé, solo me dice que las matrices no son iguales y no se cual es la razón.
public class Ejercicio19 {
public static void main(String[] args) {
Scanner entrada = new Scanner (System.in);
int matriz [][] = new int [2][3];
int matriz2 [][] = new int [2][3];
System.out.println("Ingrese valores");
for (int i = 0; i < 2; i++){
for (int j = 0; j < 3; j++){
System.out.println("Ingrese numero primer matriz");
matriz[i][j] = entrada.nextInt();
}
}
for (int i = 0; i < 2 ; i++){
for (int j = 0; j < 3; j++){
System.out.println("Ingrese numero segunda matriz");
matriz2[i][j] = entrada.nextInt();
}
}
for (int i = 0; i < 2; i++){
System.out.println(" ");
for (int j = 0; j < 3; j++){
System.out.print(matriz[i][j]+" ");
}
}
for (int i = 0; i < 2 ; i++){
System.out.println(" ");
for (int j = 0; j < 3; j++){
System.out.print(matriz2[i][j]+" ");
}
}
for (int i = 0; i < 2; i++){
for (int j = 0; j < 3 ; j++){
if (Arrays.equals(matriz, matriz2)){
System.out.println("son iguales");
}
else{
System.out.println("no son iguales ");
}
}
}
}
}
if Arrays.deepEquals(matriz1, matriz2){}
Arrays.deepEquals() se utiliza para verificar si dos matrices de matrices unidimensionales o multidimensionales son iguales o no.