Java Arrays Sort Double


Java Arrays Sort Double

package com.codingdict;

import java.util.Arrays;

public class ArrayDemo {
   public static void main(String[] args) {

      // initializing unsorted double array
      double dArr[] = {3.2, 1.2, 9.7, 6.2, 4.5};

      // let us print all the elements available in list
      for (double number : dArr) {
         System.out.println("Number = " + number);
      }

      // sorting array
      Arrays.sort(dArr);

      // let us print all the elements available in list
      System.out.println("The sorted double array is:");
      for (double number : dArr) {
         System.out.println("Number = " + number);
      }
   }
}