title: how to write one and two dimensional array into a text file in Java
body: <p>I want to write each elements of arrays into a text file. Eg below will demonstrate more clearly</p>
  
  <pre><code>String[] Name = {"Eric","Matt","Dave"}
  
  Int[] Scores = {[45,56,59,74],[43,67,77,97],[56,78,98,87]}
  
  double[] average = {45.7,77.3,67.4}
  </code></pre>
  
  <p>I want the following in the text file</p>
  
  <pre><code>Student Eric scored 45,56,59,74 with average of 45.7
  Student Matt scored 43,67,77,97 with average of 77.3
  Student Dave scored 56,78,98,87 with average of 67.4
  </code></pre>
  
  <p>I created output file</p>
  
  <pre><code>PrintStream output = new PrintStream(new File("output.txt"));
  </code></pre>
  
  <p>I used a for loop</p>
  
  <pre><code>for(int i =0;i&lt;=Name.length;i++){
  
      output.println("Student  " + Name[i] + " scored " + Scores[i] + " with average of " + average[i]);
  }
  </code></pre>
  
  <p>But this did not work. Please help.</p>