Java Arrays binarySearch方法 Java Arrays asList方法 Java Arrays binarySearch方法 Java Arrays binarySearch方法 package com.codingdict; import java.util.Arrays; public class ArrayDemo { public static void main(String[] args) { // initializing unsorted byte array byte byteArr[] = {10,20,15,22,35}; // sorting array Arrays.sort(byteArr); // let us print all the elements available in list System.out.println("The sorted byte array is:"); for (byte number : byteArr) { System.out.println("Number = " + number); } // entering the value to be searched byte searchVal = 35; int retVal = Arrays.binarySearch(byteArr,searchVal); System.out.println("The index of element 35 is : " + retVal); } } Java Arrays asList方法 Java Arrays binarySearch方法