gpt4 book ai didi

java - 新 ConcurrentHashMap 新 ConcurrentHashMap

转载 作者:行者123 更新时间:2023-12-01 06:52:56 28 4
gpt4 key购买 nike

我正在尝试使用 ConcurrentHashMap 初始化 ConcurrentHashMap

private final ConcurrentHashMap<
String,
ConcurrentHashMap<String, Double>
> myMulitiConcurrentHashMap = new ConcurrentHashMap<
String,
new ConcurrentHashMap<String, Double>()
>();

但是javac给出了

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>()

指向第二个new

如何正确地new初始化myMulitiConcurrentHashMap

最佳答案

您没有初始化内部 ConcurrentHashMap<String, Double> ;只需执行以下操作即可:

new ConcurrentHashMap<
String,
ConcurrentHashMap<String, Double>
>();

关于java - 新 ConcurrentHashMap 新 ConcurrentHashMap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20318655/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com