Logo

Programming-Idioms

History of Idiom 8 > diff from v52 to v53

Edit summary for version 53 by scott_s:
New Java implementation by user [scott_s]

Version 52

2019-09-26, 19:18:36

Version 53

2019-09-26, 19:36:58

Idiom #8 Initialize a new map (associative array)

Declare a new map object x, and provide some (key, value) pairs as initial content.

Idiom #8 Initialize a new map (associative array)

Declare a new map object x, and provide some (key, value) pairs as initial content.

Extra Keywords
table dictionary hash
Extra Keywords
table dictionary hash
Imports
import java.util.Map;
import java.util.HashMap;
Code
final Map<String, Integer> x = new HashMap<String, Integer>() {{
    put("one", 1);
    put("two", 2);
    put("three", 3);
}};