日期:2014-05-20 浏览次数:20814 次
public class Test2 { public static char[] sort(char[] arrch){ if(arrch==null||arrch.length==0) return arrch; char temp='-'; int length=arrch.length; for(int i=0;i<length;i++){ for(int j=0;j<length-1;j++){ if(arrch[j]<arrch[j+1]){ temp=arrch[j]; arrch[j]=arrch[j+1]; arrch[j+1]=temp; // for(char b:arrch){ // System.out.print(b+","); // } // System.out.println(); } } } return arrch; } public static void main(String[] args) { char[] a={'a','A','k','Z'}; // for(char b:a){ // System.out.println((int)b); // } a=sort(a); for(char i:a){ System.out.print(i+","); } } }