title: How to manipulate arrays. Find the average. Beginner Java
body: <p>I have a homework assignment and I was wondering if anyone could help me as I am new to Java and programming and am stuck on a question. The question is: </p>
  
  <p>The first method finds the average of the elements of an integer array:</p>
  
  <pre><code>public double average(int[] data)
  </code></pre>
  
  <p>That is, given an integer array, data, calculate the average of its elements are return the average value. For example, the average of {1, 3, 2, 5, 8} is 3.8. </p>
  
  <p>Here is what I have done so far: </p>
  
  <pre><code>public double average(int[] data) {  
      int sum = 0;
  
      while(int i=0; i &lt; data.length; i++) 
  
      sum = sum + data[i]; 
      double average = sum / data.length;; 
  
      System.out.println("Average value of array element is " " + average);
  }
  </code></pre>
  
  <p>When compiling it I get an error message at the <code>int i=0</code> part saying '.class expected'. Any help would be appreciated. </p>