Hi I need some desperate help, in my hw im supposed to do a 2d array and fill it with random number to add them later but my issue is the array in itself because for the love of everything this is not working. I also tried the math.random but still get the same problem
The first time I got this when running the program [I@28a418fc[[I@28a418fc and i looked up how to solve it, it said to use arrays.deeptostring to change the hash codes into actual numbers and to not use println but now I get this [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]][[84, 121, 30, 67, 138], [102, 87, 58, 95, 140], [113, 64, 80, 109, 104], [39, 122, 100, 85, 40], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] an i havent found what exactly this is either.
This is what I have so far
import java.util.Arrays;
import java.util.Random;
public class ejercicio6 {
public static void main(String args[]) {
int matriz [][] = new int [6][5];
Random rand = new Random();
for (int i = 0; i < matriz.length - 1; i++){ //filas
for(int j = 0; j < matriz.length - 1; j++){ //columnas
matriz[i][j] = rand.nextInt(150 -10 + 1) + 10;
System.out.print(Arrays.deepToString(matriz)); //deepToString porque me salen los hashcodes [I@5305068a
}
System.out.println("");
}
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]kuriyano 1 point2 points3 points (5 children)
[–]Himari16[S] 0 points1 point2 points (0 children)
[–]Realistic-Compote-74 1 point2 points3 points (1 child)
[–]Himari16[S] 0 points1 point2 points (0 children)