Java Array class sort(double[] a, int fromIndex, int toIndex) example
Array class sort(double[] a, int fromIndex, int toIndex)method example
Array class sort(double[] a, int fromIndex, int toIndex) method example. This example shows you how to use sort(double[] a, int fromIndex, int toIndex) method.This method Sorts the specified range of the specified array of doubles into ascending numerical order.
Here is the code:-
/**
* @Program that Sorts the specified range of the specified array of doubles
* into ascending numerical order.
* sort5Array.java
* Author:-RoseIndia Team
* Date:-16-May-2008
*/
import java.util.*;
public class sort5Array {
public static void main(String[] args) {
//Creating a double array
double b[]={23.4,45.6,56.7,67.4,11.23,3.4,1.1};
//Sorts the specified range of the specified array of doubles
// * into ascending numerical order.
Arrays.sort(b,3,6);
//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:- 23.4 45.6 56.7 3.4 11.23 67.4 1.1 |
|