public class Lll {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char x[] = new char[9];
System.out.print("原字符序列:");
x[0] = 'a';
x[1] = 'c';
x[2] = 'u';
x[3] = 'b';
x[4] = 'e';
x[5] = 'p';
x[6] = 'f';
x[7] = 'z';
//调用另一个方法
sortAndPrint(x);
System.out.println("\n请输入一个字符:");
String m = sc.next();
//创建数组y,长度为10
char y[] = new char[10];
//原字符数组的长度
int len = x.length;
//将x数组拷贝到y数组
for (int i = 0; i
y[i] = x[i];
}
//m是刚输入的字符串,取第一个字符插入y数组最后一个
y[9] = m.charAt(0);
//调用另一个方法排序并打印
sortAndPrint(y);
}
private static void sortAndPrint(char[] x) {
Arrays.sort(x);
System.out.print("\n升序排列后:");
for (int j = 0; j
System.out.print(x[j] + " ");
}
}
}