Search code examples
javatreemaptreemaps

Java TreeMap within TreeMap - Identifier error?


This works fine:

TreeMap <String, ArrayList> x_probs_org = new TreeMap<String, ArrayList>();

But this:

TreeMap <String, TreeMap<String, Float>> x_probs = new <String, TreeMap<String, Float>>();

causes the following error:

error: <identifier> expected

Why? What am I doing wrong? I tried a couple of other ways but I don't see why this is wrong.


Solution

  • You forgot the TreeMap identifier:

    .... = new TreeMap<String, TreeMap<String, Float>>();