티스토리 뷰

공부

[Java] init HashMap()

승가비 2020. 11. 20. 23:52
728x90
Map<String, String> myMap = new HashMap<String, String>() {{
        put("a", "b");
        put("c", "d");
    }};

https://stackoverflow.com/questions/6802483/how-to-directly-initialize-a-hashmap-in-a-literal-way

 

How to directly initialize a HashMap (in a literal way)?

Is there some way of initializing a Java HashMap like this?: Map<string,string> test = new HashMap<string, string="">{"test":"test","test":"test"}; What would be the correct syntax? I</string,></string,string>

stackoverflow.com

 

728x90

'공부' 카테고리의 다른 글

[Kafka] reset-offsets  (0) 2020.11.21
[Hive] How to copy table  (0) 2020.11.20
[SQL] ORDER BY RAND()  (0) 2020.11.20
[SQL] SHOW CREATE TABLE table;  (0) 2020.11.20
[HTTP] header is case-insensitive  (0) 2020.11.20
댓글