I use the following lines to sort an array of floats in reverse order, but I got an error message, what's wrong ?
float sortedData[]=new float[100];
...
Arrays.sort(sortedData,Collections.reverseOrder());
Error : cannot find symbol
symbol : method sort(float[],java.util.Comparator) location: class java.util.Arrays Arrays.sort(sortedData,Collections.reverseOrder());
=========================================================================
I was confused because in Jdk1.6 api, I saw this : [ Arrays ] public static void sort(float[] a), it doesn't say : public static void sort(Float[] a)
That specific method, takes an array of type Object. The type float does not extend the Object class, but Float does.
Float sortedData[]=new Float[100];
...
Arrays.sort(sortedData,Collections.reverseOrder());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With