Instantiating a TreeMap using a Comparator which should be able to access the said TreeMap
问题 I'm trying to instantiate a TreeMap using a Comparator which should be able to access the said TreeMap , i.e. the one it will be used for (I guess that " will " must precisly be the problem...): final Map<String, Integer> map = new TreeMap<String, Integer>(new Comparator<String>() { @Override public int compare(String o1, String o2) { Integer i = map.get(o1); // Error: "the local variable map may not have been initialized" return ...; } }); I can get why this error occurs, since when