Table of Content

How to sort elements in Double Array using Index in Java?


Declaration :

Explanation :

Purpose The java.util.Arrays.sort(double[] a int fromIndex int toIndex) method sorts the specified range of the specified array of doubles into ascending numerical order. The range to be sorted extends from index fromIndex inclusive to index toIndex exclusive.
Parameters a ===> This is the array to be sorted.
fromIndex ===> This is the index of the first element (inclusive) to be sorted.
toIndex ===> This is the index of the last element (exclusive) to be sorted .
Return Value This method does not return any value.
Exception IllegalArgumentException — if fromIndex > toIndex
,ArrayIndexOutOfBoundsException — if fromIndex < 0 or toIndex > a.length

Java Program : Example

Below example will explain java.util.Arrays.sort() method.

Output of Program :