title: how to call a function on array (java)?
body: <p>I'm trying to calculate the average of numbers in the array. Unlike Python, the following does not work for me:
  <a href="https://i.stack.imgur.com/9ly57.png" rel="nofollow noreferrer">not working</a></p>
  
  <p>However, if I do <a href="https://i.stack.imgur.com/umshk.png" rel="nofollow noreferrer">this</a> everything is okay.</p>
  
  <p>Is there a way to make it work like in Python? Without allocate a variable to the input-array?</p>
  
  <p>My code:</p>
  
  <pre><code>public class TestTwo {
  
      public static void main(String[] args) {
          double[] arx = {1,2.0,4,5,6,7.0};
          System.out.println(average(arx));
      }
  
      public static double average(double [] args) {
          double sum = 0.0;
          for (double d : args) {
              sum += d;
          }
          return sum / args.length;
      }   
  }
  </code></pre>