帮我看看这个程序那里错了(j2se)?
题目要求:用折半查找法判断一个从键盘上输入的数是否在某个数组中。代码:mport java.util.*;
public class SortFind {
public static void main(String args[]) {
int n=0, low, high, middle;
System.out.println("从键盘输入一个整数,程序将判断该数是否在一个数组中");
int a[] = {12,34,9,-23,45,6,45,90,123,19,34};
Arrays.sort(a);
Scanner reader = new Scanner(System.in);
while(reader.hasNextInt()){
n = reader.nextInt();
low = 0;
high= a.length;
middle = (low + high)/2;
while (low<=high) {
middle = (low + high)/2;
if (n == a[middle] ) {
System.out.println(n + "是数组中的元素");
break;
} else if (n < a[middle]) {
high=a[middle]-1;
} else {
low=a[middle]+1;
}
}
if (low==high) {
System.out.println(n + "不在数组中");
}
}
System.out.println("\n可继续输入整数,或输入非整数结束程序");
System.out.println("你输入的数据不是整数");
}
}