Table of Content

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

Declaration :

Explanation :

Purpose The java.util.Arrays.sort(byte[] a int fromIndex int toIndex) method sorts the specified range of the specified array of bytes 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 :