public static void main(String[] args) {
Map>> map = getHashMap();
}
static Map getHashM
The getHashMap
function does not have to infer the types. It's at the call site that javac is required by the Java Language Spec to infer that the types agree (15.12.2.7 Inferring Type Arguments Based on Actual Arguments).
I believe the current plan is (still) for JDK7 to support the diamond operator, so this sort of thing will work with new
too, although with a bit of apparently pointless syntax.
Map>> map = new HashMap<>();
^^diamond