集册 Java实例教程 将双数组按升序排序

将双数组按升序排序

欢马劈雪     最近更新时间:2020-01-02 10:19:05

564
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
将双数组按升序排序

import java.util.Arrays;
/**
 from
* 时代Java - nowjava.com 
**/


public class Main 

{

   public static void main(String[] args)

   {

      // sort doubleArray into ascending order

      double[] doubleArray = {8.4, 9.3, 0.2, 7.9, 3.4};

      Arrays.sort(doubleArray); 

      System.out.printf("%ndoubleArray: ");


      for (double value : doubleArray)

        System.out.printf("%.1f ", value);

   } 
   /*
   来 自*
    时代Java公众号 - N o w J a  v a . c o m
   */


   // output values in each array

   public static void displayArray(int[] array, String description)

   {     

      System.out.printf(
展开阅读全文