title: Returning an array from a method with user input in java
body: <p>I'm getting an illegal start of expression error next to <code>public static double getAverage (double average) {</code></p>
  
  <p>I'm also getting an error stating "Variable average is not used" next to <code>double average = sum /(double) arr.length;</code></p>
  
  <p>I've been working it for a while, I'm not sure what to do anymore.
  Any suggestions?</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Average {
  
    public static void main(String [] args){                    
      Scanner input = new Scanner(System.in);
      System.out.print("How many numbers you want to display: ");
  
      int n=input.nextInt();
      System.out.println("Enter array values: ");
  
      int arr [] = new int[n];
      int sum=0;
  
      for(int i = 0; i &lt; arr.length; i++) {
        arr[i] = input.nextInt();
        sum+=arr[i];
        double average = sum / (double) arr.length;
  
        public static double getAverage(double average){     
          System.out.println("Average value of array: " + average);
          {
            return average; 
          }
        }
      }
  </code></pre>