我正在寻找 Integer not int 但 Integer 的含义是有问题的代码
public class BasicSearch {
public static final int NOT_FOUND = -1;
public static int binarySearch(Integer[] a, int x)
{
int low=0;
int high = a.length - 1;
int mid;
while (low <= high)
{
mid = (low + high) / 2;
if (a[mid].compareTo(x)<0)
low = mid + 1;
else if (a[mid].compareTo(x) > 0)
high = mid -1;
else
return mid;
}
return NOT_FOUND;
}
public static void main(String[] args)
{
int SIZE = 8;
Integer[] a = new Integer[SIZE];
for (int i=0; i<SIZE; i++)
a[i] = new Integer(i * 2);
for (int i=0; i<SIZE*2; i++)
System.out.println("Found " + i + " at " + binarySearch(a, new Integer(i)));
}
}
我不知道整数是关键字还是什么我可以得到任何帮助吗?