import java.util.Random;
class Main {
public static void main(String[] args) {
int tama = 5;
llenarMatriz(tama);
}
public static void llenarMatriz(int x) {
Random aleatorio = new Random(System.currentTimeMillis());
String abc[][] = new String[x][x];
for (int filas = 0; filas < x; filas++) {
for (int columnas = 0; columnas < x; columnas++) {
int intAleatorio = aleatorio.nextInt(100); // números entre 0 y 99
abc[filas][columnas] = String.valueOf(intAleatorio);
}
}
// Construir la salida en formato de matriz
String salida = "";
for (int i = 0; i < x; i++) {
for (int j = 0; j < x; j++) {
salida += abc[i][j] + "\t";
}
salida += "\n";
}
// Mostrar en consola
System.out.println(salida);
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: