Ver Mensaje Individual
  #5 (permalink)  
Antiguo 14/12/2012, 03:23
Avatar de DCienfuegos
DCienfuegos
 
Fecha de Ingreso: febrero-2009
Ubicación: Asturias
Mensajes: 195
Antigüedad: 15 años, 3 meses
Puntos: 3
Pregunta Respuesta: Rellenar matriz con numeros aleatorios

Tengo la matriz echa con el siguiente codigo:

Código:
public void crearMatriz(int size)
    {
        if(size>0 && size <= MAX_SIZE) 
        this.size=size;
        {
            int matriz[][] = new int[size][size];        
                for(int i=0; i<size; i++) {
                    for(int j=0; j<size; j++) {          // recorro la matriz
                        Random r = new Random();         // para generar aleatoriamente
                        matriz[i][j] = r.nextInt(50+1);  //relleno aleatoriamente
                    }
                }
            }
    }
Todo compila y se deja ejecutar, pero cuando voy a ver la matriz, sus campos estan null (salvo el de dimensiones), vamos, que no me rellena aleatoriamente la matriz con los numeros, me lo deja vacio.. ¿Por que?