Java examples for Language Basics:char
Sort char Array
import java.util.Arrays; public class Main { public static void main(String[] args) { char[] c1 = new char[]{'d','a','f','k','e'}; /* ww w . ja v a2s . c o m*/ System.out.println("Original Array :"); for(int index=0; index < c1.length ; index++) System.out.print(" " + c1[index]); Arrays.sort(c1); System.out.println("\nSorted char array : "); for(int index=0; index < c1.length ; index++) System.out.print(" " + c1[index]); char[] c2 = new char[]{'d','a','f','k','e'}; Arrays.sort(c2,1,4); //print sorted char array System.out.println("\nPartially Sorted char array : "); for(int index=0; index < c2.length ; index++) System.out.print(" " + c2[index]); } }