public void sortDescending(double[]numbers){
        System.out.println("Array values in descending order ......");
        Double[] objDouble=new Double[11]; // Double object array initialization
        
        for(int counter=0;counter<11;counter++){
            objDouble[counter]=Double.valueOf(numbers[counter]); // Converts the primitive type values of the primitive array into object type and assigning to the Double object array 
        }
        
        Arrays.sort(objDouble,Collections.reverseOrder()); //Sort the Double object array
        
        for(Double nums:objDouble){
            System.out.println(nums);
        }
    }
Sunday, March 30, 2014
A method to sort an primitive type array to descending order in JAVA
Subscribe to:
Comments (Atom)
