无法编译此 prog 4 在数组中搜索数字.. .class 在 prog 的最后一行出现预期错误:obj.searchnumber(int arr1[],item);
import java.util.*;
public class Ans5
{
public void searchnumber(int arr[],int item){
int low = 0;
int high = arr.length-1;
int mid;
while (low <= high) {
mid = (low + high) / 2;
if (arr[mid] > item) high = mid - 1;
else if (arr[mid] < item) low = mid + 1;
else
System.out.println("The searched item"+item+"is found in the array");
}
}
public static void main(String args[]) {
Ans5 obj= new Ans5();
Scanner sc=new Scanner(System.in);
int arr1[]={1,2,3,4,5,6,7,8,9};
System.out.print("\fEnter the item u need to search: ");
int item=3;//sc.next();
obj.searchnumber(int arr1[],item); // here's the error shown at arr1[]
}
}