执行了什么,importjava.util.Arrays;publicclass Test {public static void main(String[] unused) {String[] str = {"xxx","zzz","yyy","aaa"};Arrays.sort(str);intindex=Arrays.binarySearch(str,"zzz");if(index==-1)System.out.println("no");elseSystem.out.

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/24 21:28:47
执行了什么,importjava.util.Arrays;publicclassTest{publicstaticvoidmain(String[]unused){String[]str={"xxx"

执行了什么,importjava.util.Arrays;publicclass Test {public static void main(String[] unused) {String[] str = {"xxx","zzz","yyy","aaa"};Arrays.sort(str);intindex=Arrays.binarySearch(str,"zzz");if(index==-1)System.out.println("no");elseSystem.out.
执行了什么,
importjava.util.Arrays;
publicclass Test {
public static void main(String[] unused) {
String[] str = {"xxx","zzz","yyy","aaa"};
Arrays.sort(str);
intindex=Arrays.binarySearch(str,"zzz");
if(index==-1)
System.out.println("no");
else
System.out.println("yes");
}
}
A)no B) xxx C)0 D) yes

执行了什么,importjava.util.Arrays;publicclass Test {public static void main(String[] unused) {String[] str = {"xxx","zzz","yyy","aaa"};Arrays.sort(str);intindex=Arrays.binarySearch(str,"zzz");if(index==-1)System.out.println("no");elseSystem.out.
importjava.util.Arrays;               // 导入util.Arrays类
publicclass Test {    
    public static void main(String[] unused) {        
        String[] str = {"xxx","zzz","yyy","aaa"}; //定义字符串数组       
        Arrays.sort(str);                         //对字符串数组的内容进行排序       
        intindex=Arrays.binarySearch(str,"zzz");  //使用二分法查找字符串数组str中是否包含“zzz”字符串       
        if(index==-1)                             // binarySearch函数如果查找失败即返回-1
            System.out.println("no");             //打印no       
        else            
            System.out.println("yes");            //如果找到,打印yes
    }
}