Basically, it allows you to do this:
callAPIThatTakesAMap(Collections.singletonMap(key, value));
rather than this:
Mapm = new HashMap ();m.put(key, value);callAPIThatTakesAMap(m);
which is much nicer when you only have a single key/value pair. This situation probably does not arise very often, but singleton() and singletonList() can quite frequently be useful.
参考 :