刚开始学真的难死我了
public static void main(String [] args){
Scanner sc=new Scanner(System.in);
String [] arr={"a","b","c","e","f","p","u","z"};
System.out.print("原字符序列是:");
for(int i=0;i<arr.length;i++){
System.out.print(arr[i]+" ");//这里把原字符序列输出一下
}
System.out.println();
System.out.print("待插入的字符是:");
String zf=sc.next();
String arr1[]=Arrays.copyOf(arr, 9);//这里是把原本arr数组8的长度扩展到9的长度
arr1[8]=zf;//插入的就在新数组的最后
Arrays.sort(arr1);//把arr1数组排序
int b=Arrays.binarySearch(arr1,zf);//binarySearch查询zf在数组arr1中的下标
System.out.println("插入字符的下标是:"+b);
System.out.println("插入后的序列是:");
for(int i=0;i<arr1.length;i++){
System.out.print(arr1[i]+" ");//输出插入排序后
}
}