NikonJR NikonJR -4 years ago 154
Java Question

How to get specific key value from a nested TreeMap

Say I have the TreeMap,

TreeMap<String,TreeMap<String,TreeMap<String,String>>> map = new TreeMap<>();

and there are two values,


where mapToTree is a method for storing values into the nested TreeMap.

I know that to get a value that is in the last value position I would do,


but how would I get the key value in 1,2? Currently when I do


it prints "{111=null}."

Answer Source
  1. You can get the entire keySet and iterate

  2. For the case if you are only interested in the first key, value pair you can use -

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download