Answers for "initializing hashmap with keys and values in java"

-1

initialize hashmap with values

public static Map<String, String> articleMapOne;
static {
    articleMapOne = new HashMap<>();
    articleMapOne.put("ar01", "Intro to Map");
    articleMapOne.put("ar02", "Some article");
}
Posted by: Guest on August-11-2021
-1

initialize hashmap with values

Map<String, String> doubleBraceMap  = new HashMap<String, String>() {{
    put("key1", "value1");
    put("key2", "value2");
}};
Posted by: Guest on December-03-2021

Code answers related to "initializing hashmap with keys and values in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language