title: How to associate variable in array result
body: <p>I'm studying Java basics from the beginning. But there is still some theoretical basis.</p>
  
  <p>How do I calculate the average of each student in the example below?</p>
  
  <pre><code>    package teste01classes;
  
      public class Metodos {
  
          static void Media(Alunos[] aluno) {
              // SEE HERE.
              double[] media;
              for (int i = 0; i &lt; aluno.length; i++) {
                  media[i] = (aluno[i].n1 + aluno[i].n2 + aluno[i].n3) / 3;
                  System.out.println(aluno[i].nome + media[i]);
              }
          }
      }
  
  
  
  package teste01classes;
  
  // Classe Alunos com os campos
  public class Alunos {
      String nome;
      int n1, n2, n3;
  }
  
  
  
  package teste01classes;
  
  public class Teste01Classes {
  
      public static void main(String[] args) {
  
          Alunos[] aluno = DadosAlunos.createAlunos();
  
      }
  }
  </code></pre>