Java Array class sort(char[] a) example
Array class sort(char[] a) method example
Array class sort(char[] a) method example. This example shows you how to use sort(char[] a) method.This method Sorts the specified array of chars into ascending numerical order.
Here is the code:-
/**
* @Program that Sorts the specified array of chars into ascending numerical
* order.
* sort2Array.java
* Author:-RoseIndia Team
* Date:-16-May-2008
*/
import java.util.*;
public class sort2Array {
public static void main(String[] args) {
//Creating a chars array
char b[]={'R','O','S','E','I','N','D','I','A'};
//Sorts the specified array of chars into ascending numerical
//* order.
Arrays.sort(b);
//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(b[i]);
}
} |
Output of the program:-
The array of bytes into ascending order is:-
01122334556789 |
|