The following piece of code was instrumental to an iOS app I finished recently:
var closestLocation: CLLocation?
var smallestDistance: CLLocationDistance?
for location in locations {
let distance = currentLocation.distanceFromLocation(location)
if smallestDistance == nil || distance < smallestDistance {
closestLocation = location
smallestDistance = distance
}
}
My question is pretty simple: how would this piece of code look in Java for Android Studio?
This is my first run at Java and Android Studio, so any help would be greatly appreciated.