Java Arrays Sort Float Index


Java Arrays Sort Float Index

package com.codingdict;

import java.util.Arrays;

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

      // initializing unsorted float array
      float fArr[] = {3.1f, 1.4f, 2.7f, 11.5f, 8.7f};

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

      // sorting array from index 0 to 3
      Arrays.sort(fArr, 0, 3);

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