<分区>
我有以下代码:
Map<String, Map<Double, String>> map = new HashMap<>();
Map<Double,String> Amap = new HashMap<>();
map.put(getValuesTypes.FUT(), HERE);
我不是先创建一个 Map 并将其放在“HERE”,而是在 Arrays.asList(...)
这样我就可以在 "Here"?.asMap({1.0,"A"}, {2.0,"B"})
标签 java list dictionary
<分区>
我有以下代码:
Map<String, Map<Double, String>> map = new HashMap<>();
Map<Double,String> Amap = new HashMap<>();
map.put(getValuesTypes.FUT(), HERE);
我不是先创建一个 Map 并将其放在“HERE”,而是在 Arrays.asList(...)
这样我就可以在 "Here"?.asMap({1.0,"A"}, {2.0,"B"})
最佳答案
你可以像这样初始化HashMap
。
new HashMap<Double, String>() {
{
put(1.0, "ValA");
put(2.0, "ValB");
}
};
关于java - Arrays.asList 也用于 map ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40449848/