title: Pass array to method and return the array
body: <p>Here is the question I am working on </p>
  
  <p>Use a for loop to generate an array of ten random integers, all in the range from 100 to 200, inclusive. Use the Arrays class to both sort and display the entire array. <strong>Next, pass the array as the sole argument to a method that doubles each element of the array and then returns the array.</strong> Use a foreach loop to show all elements in the returned array on one line separated by a single space. This latter loop should also determine the sum of all elements in the returned array. Display the sum with a "thousands" comma as in the sample output.</p>
  
  <p>And here is my code:</p>
  
  <pre><code>package bryant7and8;
  
  import java.util.Arrays;
  
  
  public static void main(String[] args) {
  
      int[] myList = new int[10];
  
          for (int i = 0; i &lt; myList.length; i++) {
              myList[i] = 100 + (int) (Math.random() * ((110 - 10) + 1));
  
      }
      Arrays.sort(myList);
      System.out.println(Arrays.toString(myList));
  
      doubleArray (myList);
      System.out.println(doubleArray(myList));
  }
  
  public static int[] doubleArray(int[] array) {
      for (int i = 0; i &lt; array.length; i++) {
          array[i] *= 2;
      }
  
      return array;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I cannot figure out how to pass the array, I have been at it for a few hours and my books explanation is not helping. Also I apologize for such horrible question formatting I'm still new to stackoverflow.</p>