No, there are no literals in Java, but they have array literals.
static final Map<String, String> map; static { map = new HashMap<String, String>(); String[][] pairs = { {"foo", "bar"}, {"x", "y"} }; for (String[] pair : pairs) { map.put(pair[0], pair[1]); } }
Of course, this does not add anything to direct copying and pasting put , and it will not work if your key and value types do not match.
rlibby
source share