View Subcategory

Define an empty map

java
Map map = new HashMap();

Define an unmodifiable empty map

java
Map empty = Collections.EMPTY_MAP;
SortedMap empty = MapUtils.EMPTY_SORTED_MAP;

Define an initial map

Define the map {circle:1, triangle:3, square:4}
java
Map shapes = new HashMap();
shapes.put("circle", 1);
shapes.put("triangle", 3);
shapes.put("square", 4);
Map shapes = new HashMap() {{ put("circle",1); put("triangle",3); put("square",4); }}