I have a set of data that I want to store in a simple variable. Basically a list of fifteen names with location coordinates. In Python I'd create a dict, something like:
locations = {'Location1': [lat1, lon1], 'Location2': [lat2, lon2], ...}
So that way I can later call the coordinates by using the location name as key:
coords = locations['Location1']
Any equivalent to do this in Java? I basically want to define these locations as a constant in my code.
EDIT after receiving the first very fast replies:
I have now added this:
private class coordinates {
private Long lat;
private Long lon;
public Long getLat() {
return lat;
}
public void setLat(Long lat) {
this.lat = lat;
}
public Long getLon() {
return lon;
}
public void setLon(Long lon) {
this.lon = lon;
}
}
private final static Map<String, coordinates> LOCATIONS;
The last line is of course incomplete; I'm at a loss on how to populate this thing, without using extra temporary variables to access the two setters, resulting in several lines of code for every single set of values.