提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
排序字符数组
import java.util.Arrays; public class Main { /**来自 n o w j a v a . c o m - 时代Java**/ public static void main(String[] args) { char[] c1 = new char[]{'d','a','f','k','e'}; 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 : ");/*from 时 代 J a v a 公 众 号 - N o w J a v a . c o m*/ 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