Java Arrays Sort Float


Java Arrays Sort Float

package com.codingdict;

import java.util.Arrays;

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

      // initializing unsorted float array
      float fArr[] = {3.2f, 1.2f, 9.7f, 6.2f, 4.5f};

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

      // sorting array
      Arrays.sort(fArr);

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