title: Java: error whilte sorting an array with built in function
body: <p>I am trying to sort an array with <code>array.sort(arr)</code> but there is an error which I do not understand. I tried renaming my arrays to different putting brackets in different places</p>
  
  <pre><code>public static int HW2K ()
      {     
        int [] arr = {50,40,60,20,10};
        int i = arr.length;
        int secondlargest = arr[i-1]; 
  
        Arrays.sort(arr);
        return secondlargest;  
  
      }
  </code></pre>
  
  <p>it should return the second largest number</p>