Java Array class sort(float[] a, int fromIndex, int toIndex) example
Array class sort(float[] a, int fromIndex, int toIndex) method example
Array class sort(float[] a, int fromIndex, int toIndex) method example. This example shows you how to use sort(float[] a, int fromIndex, int toIndex) method.This method Sorts the specified range of the specified array of floats into ascending numerical order.
Here is the code:-
/**
* @Program that Sorts the specified range of the specified array of floats
* into ascending numerical order.
* sort7Array.java
* Author:-RoseIndia Team
* Date:-16-May-2008
*/
import java.util.*;
public class sort7Array {
public static void main(String[] args) {
//Creating a float array
float b[]={23.4f,45.6f,56.7f,67.4f,11.23f,3.4f,1.1f};
// Sorts the specified range of the specified array of floats into ascending
//numerical order.
Arrays.sort(b,0,7);
//Displays the array
System.out.print("The array of bytes into ascending order is:-");
for(int i=0;i<b.length;i++)
System.out.print("\t"+b[i]);
}
} |
Output of the program:-
| The array of bytes into ascending order is:- 1.1 3.4 11.23 23.4 45.6 56.7 67.4 |
|