Java Array class sort(byte[] a, int fromIndex, int toIndex) example
Array class sort(byte[] a, int fromIndex, int toIndex) method example
Array class sort(byte[] a, int fromIndex, int toIndex)method example. This example shows you how to use sort(byte[] a, int fromIndex, int toIndex) method.This method Sorts the specified range of the specified array of bytes into ascending numerical order
Here is the code:-
/**
* @Program that Sorts the specified range of the specified array of bytes
* into ascending numerical order
* sort1Array.java
* Author:-RoseIndia Team
* Date:-16-May-2008
*/
import java.util.*;
public class sort1Array {
public static void main(String[] args) {
//Creating a byte array
byte b[]={9,1,2,3,4,5,3,5,6,2,1,7,8,0};
//Sorts the specified range of the specified array of bytes
//* into ascending numerical order
Arrays.sort(b,0,14);
//Displays the array
System.out.println("The array of bytes into ascending order is:-");
for(int i=0;i<b.length;i++)
System.out.print(b[i]);
}
} |
Output of the program:-
The array of bytes into ascending order is:-
01122334556789 |
|