I have a class
public class LocationDistances {
String locs;
double distances;
}
and an ArrayList composed of LocationDistances objects in another class
ArrayList<LocationDistances> locsDis = new ArrayList(Arrays.asList(
new LocatoinDistances("abc",23.234556),
new LocatoinDistances("xyz",3.3444566),
. . .
. . .
. . .
));
How to select LocationDistances.locs from Array list on the basis of minimum value of LocationDistances.distance from the locsDis arrayList?
equalsandhashcodemethods ofObjectclass. Or you can write a Comparator to sort your list with minimum distance on top so you can retrieve it as first element in your list.