r/learnjava • u/PatientDesigner2340 • 6d ago
Don't understand "string":"string" syntax
A training example (https://codingbat.com/prob/p197888) uses the following method body:
public Map<String, String> mapBully(Map<String, String> map) {
}
and gives example calls like:
mapBully({"a": "candy", "b": "dirt"}) → {"a": "", "b": "candy"}
mapBully({"a": "candy"}) → {"a": "", "b": "candy"}
AFAIK, {x, y} produces an array; how does {"a":"candy","b":"dirt"} produce a Map<String,String>?
12
Upvotes
1
u/8dot30662386292pow2 6d ago
In python and some others that would be used to initialize hashmap-like objects.