例子:假设有一个数组{2,18,15,28},现在要把他们存入散列表,并且要根据散列表判断某一个元素是否在数组中出现。
代码:
public class HashSearch {
public static void main(String[] args) {
int m = 13;
int[] arr = new int[]{2,18,15,28};
int[] hash_table = new int[m];
for(int i=0;i= 13){
return Integer.MIN_VALUE;
}
else {i++;}
}
}
}
输出:
打印散列表: -2147483648 -2147483648 2 -2147483648 -2147483648 18 15 28 -2147483648 -2147483648 -2147483648 -2147483648 -2147483648 18在数组中是否存在? true 9在数组中是否存在? false



