Java的:如何排序花车以相反的顺序数组? [英] Java : How to sort an array of floats in reverse order?
问题描述
我用下面的行以按相反的顺序float数组,但我得到一个错误信息,有什么不对?
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
符号:方法排序(浮动[],的java.util.Comparator)
位置:类java.util.Arrays中
Arrays.sort(sortedData,Collections.reverseOrder());
symbol : method sort(float[],java.util.Comparator) location: class java.util.Arrays Arrays.sort(sortedData,Collections.reverseOrder());
=============================================== ==========================
=========================================================================
我很困惑,因为在JDK1.6 API,我看到了这一点:[数组]公共静态无效的排序(浮动 []一),它没有说:公共静态无效的排序(< STRONG>浮动 []一)
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)
推荐答案
这是具体的<一个href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/util/Arrays.html#sort%28java.lang.Object%5B%5D,%20java.util.Comparator%29\"相对=nofollow>方法,使用对象类型的数组。 float类型不扩展对象类,但浮法一样。
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());
这篇关于Java的:如何排序花车以相反的顺序数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!