title: how to fill a array of class? i need this to solve a arrayoutofboundsexception
body: <p>i want to fill array restaurante with random values. how do i do that? because when empty give me nullpointerexception exception. i already tried to do Arrays.fill put it doenst work. Or a solution for the exception</p>
  
  <pre><code>private Restaurante[] restaurante= new Restaurante[100];
  
  for (int i = 0; i &lt; lines.length; i++) {
  
      String[] row = lines[i].toString().split("-");
      identificador[i] = Integer.parseInt(row[0]);
      restaurante[i].setNome(row[1]);
      restaurante[i].setLugares(Integer.parseInt(row[2]));
      restaurante[i].setLocalidade(row[3]);
      restaurante[i].setTipoDeComida(row[4]);
      if (identificador[i] == this.id) {            
          linhasescritas[contador]=i;
          contador++;
  
          model.addRow(row);
      }
  }
  </code></pre>
  
  <p>the exception is in line restaurante[i].setNome(row[1]);</p>
  
  <p>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException</p>