I have a HashMap in Java, the contents of which (as you all probably know) can be accessed by
HashMap.get(\"keyname\");
If a have a HashMap
As others have said you can do this but you should define the map with generics like so:
Map> map = new HashMap>();
However, if you just blindly run the following:
map.get("keyname").get("nestedkeyname");
you will get a null pointer exception whenever keyname is not in the map and your program will crash. You really should add the following check:
String valueFromMap = null;
if(map.containsKey("keyname")){
valueFromMap = map.get("keyname").get("nestedkeyname");
}