Arrays.asList also for maps?

PowerFlower :

I have the below code:

Map<String, Map<Double, String>> map = new HashMap<>();
Map<Double,String> Amap = new HashMap<>();
map.put(getValuesTypes.FUT(), HERE);

Instead of creating a Map first and put it at "HERE", I'm looking for a function like I could use with a List there Arrays.asList(...) so that i can just enter at "Here" ?.asMap({1.0,"A"}, {2.0,"B"})

nakano531 :

You can initialize HashMap like this.

new HashMap<Double, String>() {
    {
        put(1.0, "ValA");
        put(2.0, "ValB");
    }
};

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=451424&siteId=1