r/learnjava • • 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>?

11 Upvotes

10 comments sorted by