storing hashMap in a hashMap

后端 未结 5 1171
孤街浪徒
孤街浪徒 2020-12-25 14:46

i am reading data from a text file and want to store HashMap in another HashMap..

HashMap>

how to

5条回答
  •  [愿得一人]
    2020-12-25 15:33

    Example:

    Creating and populating the maps

    Map> outerMap = new HashMap>();
    Map innerMap = new HashMap();    
    innerMap.put("innerKey", new Value());
    

    Storing a map

    outerMap.put("key", innerMap);
    

    Retrieving a map and its values

    Map map = outerMap.get("key");
    Value value = map.get("innerKey");
    

提交回复
热议问题