The code works when I used java.util.Arrays.sort(numbers);
Am I doing something wrong? This seems weird to me.
import java.util.Arrays.*;
class
It's a static method of the class Arrays.
You should invoke it like this:
Arrays.sort(someArray);
Note you still have to import the Arrays class like this:
import java.util.Arrays;
Or as others have mentioned, if you do a static import you can omit the class name.
I would argue that Arrays.sort()
is better for readability.