Java 如何对一组双精度数组进行气泡排序?

Java 如何对一组双精度数组进行气泡排序?,java,double,bubble-sort,Java,Double,Bubble Sort,我是一个新手,我想使用bubblesort算法对数组进行排序。这就是我到现在为止所做的 public class Storename { public static void main(String[] args) { double[] revenues = {36372.92, 93784.52, 23466.24, 97744.98, 30243.70, 103362.26, 108232.71, 78513.01, 61711.97, 13268.60, 85281.88,

我是一个新手,我想使用bubblesort算法对数组进行排序。这就是我到现在为止所做的

public class Storename {

public static void main(String[] args) {
    double[] revenues = {36372.92, 93784.52, 23466.24, 97744.98, 30243.70,   103362.26, 108232.71, 78513.01, 61711.97, 13268.60, 85281.88, 50308.06, 68102.39, 18335.74, 15146.26, 96230.22, 26291.95, 53778.41, 84727.77, 91674.64, 45650.94, 101584.65, 107373.77, 25650.34, 51512.09, 54565.04, 82806.54, 31565.73, 97256.94, 45216.76};

    bubbleSort(revenues);
}

private static void bubbleSort(double[] revenues) {
    int n = revenues.length;
    int temp = 0;

    for(int i=0; i < n; i++){
        for(int j=1; j < (n-i); j++){

            if(revenues[j-1] > revenues[j]){
                //swap the elements!
                temp = revenues[j-1];
                revenues[j-1] = revenues[j];
                revenues[j] = temp;
                System.out.print(revenues[i] + " ");
            }
        }
    }
}
}
公共类Storename{
公共静态void main(字符串[]args){
双[]收入={36372.92、93784.52、23466.24、97744.98、30243.70、103362.26、108232.71、78513.01、61711.97、13268.60、85281.88、50308.06、68102.39、18335.74、15146.26、96230.22、26291.95、53778.41、84727.77、91674.64、45650.94、101584.65、107373.77、25650.34、51512.09、54565.04、828065、256.9776;
bubbleSort(收入);
}
私人静态void bubbleSort(双[]收入){
int n=收入。长度;
内部温度=0;
对于(int i=0;i收入[j]){
//交换元素!
温度=收入[j-1];
收入[j-1]=收入[j];
收入[j]=临时工资;
系统输出打印(收入[i]+“”);
}
}
}
}
}

您的温度应该是两倍而不是整数。
调用
bubbleSort(收入)后打印列表使用此代码:

for(double value:revenues)
        System.out.println(value);

就像你对其他东西进行气泡排序一样。只有数据类型会改变。