java 查找数组中最接近的一个数字

public static Integer getNumberThree(Integer[] intarray,Integer number){
int index = Math.abs(number-intarray[0]);
int result = intarray[0];
for (int i : intarray) {
int abs = Math.abs(number-i);
if(abs <= index){
index = abs;
result = i;
}
}
return result;
}
原文地址:https://www.cnblogs.com/austinspark-jessylu/p/11271525.html