Traditional:
Better (via Google Guava):
source
private HashMapindexMap = new HashMap ();
indexMap .put("low", 1); indexMap.put("medium",2);
indexMap.put("high",3);
Better (via Google Guava):
ImmutableMapindexMap = ImmutableMap. builder() .put("low", 0) .put("medium", 1) .put("high", 2) .build();
source