You need to sort the complete array rather than a single element:
Arrays.sort(numbers);
Better to move it outside of the for
-loop. You could use Arrays.toString
to display the contents of the array itself:
for (int i = 0; i < numbers.length; i++) {
numbers[i] = input.nextDouble();
}
Arrays.sort(numbers);
System.out.print(Arrays.toString(numbers));
Note: Class names start with an uppercase letter, e.g. MyMain
.