I would just need to add a function that iterates through the array and returns the sum of the numbers housed in the entire array.
It would be very helpful if you could add it because I've been stuck with that one since I really don't know how to do it thank you very much
public class Matriz {
private int[][] m;
public Matriz() {
this.m = new int[10][10];
this.llenarM();
}
public void llenarM() {
for (int f = 0; f < this.m.length; f++) {
for (int c = 0; c < this.m.length; c++) {
this.m[f][c] = (int) (Math.random() * 50 + 1);
}
}
}
public void mostrarM() {
for (int f = 0; f < this.m.length; f++) {
for (int c = 0; c < this.m.length; c++) {
System.out.print(this.formato(this.m[f][c] + "") + " ");
}
System.out.print("\n");
}
}
public String formato(String dato) {
int tam = dato.length();
String salida = "";
if (tam == 1) {
salida = dato + " ";
} else {
salida = dato;
}
return salida;
}