我有点问题。我从多个Beacon获取数据,然后将其放入arrayList中。现在我想要返回最近的那个。
{{1}}
答案 0 :(得分:0)
Beacon nearest = null;
double distance = Double.MAX_VALUE;
for (Beacon beacon: arrayList){
double maxDistance = beacon.getDistance();
if (maxDistance < distance) {
distance = maxDistance;
nearest = beacon;
}
}