Pacific-Design.com

    
Home Index

1. Algorithms

2. 04 Hash Map Nested

Algorithms / 04 Hash Map Nested /

Java - Nested HashMap

public static void nestedHashMap() {

    HashMap<String, HashMap<String, Object>> map = new HashMap<>();

    //--- Record 1 ---//
    map.put("key1", new HashMap<String, Object>());
    map.get("key1").put("key1a", "val1a");

    //--- Record 2 ---//
    map.put("key2", new HashMap<String, Object>());
    map.get("key2").put("key2a", "val2a");

    System.out.println("key1->key1a = " + map.get("key1").get("key1a"));
    System.out.println("key2->key2a = " + map.get("key2").get("key2a"));
}