I'm trying to initialize a ConcurrentHashMap of ConcurrentHashMaps with
private final ConcurrentHashMap<
String,
ConcurrentHashMap<String, Double>
> myMulitiConcurrentHashMap = new ConcurrentHashMap<
String,
new ConcurrentHashMap<String, Double>()
>();
but javac gives
HashMapper.java:132: error: illegal start of type
new ConcurrentHashMap<String, Double>()
^
HashMapper.java:132: error: '(' or '[' expected
new ConcurrentHashMap<String, Double>()
^
HashMapper.java:132: error: ';' expected
new ConcurrentHashMap<String, Double>()
pointing to the second new.
How can myMulitiConcurrentHashMap be newly initialized properly?
By the way, Java 7 has a more concise syntax now (the "diamond"):
You should be able to use interfaces on the left hand side, too: