Here is the question I am working on
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. Next, pass the array as the sole argument to a method that doubles each element of the array and then returns the array. 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.
And here is my code:
package bryant7and8;
import java.util.Arrays;
public static void main(String[] args) {
int[] myList = new int[10];
for (int i = 0; i < 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 < array.length; i++) {
array[i] *= 2;
}
return array;
}
}
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.