So you can create a Map and fill it with up to 10 entries using one line of code, instead of the 11 lines of code it used to take. You might ask "Why 10 and not 20 variables?" Who knows? Maybe they surveyed a collection of random Java code to find out how often people pre-filled a Map with X entries, or maybe they just picked a reasonable-sounding number.
Or maybe they thought 10 was a nice round number. A bit of a shame really, because if that was the case it would have been nicer if the maximum was 9, on account of us Java programmers being used to 0-based indexing.
I wish they had added special collection initializer syntax to the language instead, like C# did. In C#, you can initialize a Dictionary in this way:
It does. It takes Map.Entry<K, V>... as a parameter. Here, only with a different name. The syntax of varargs doesn't allow alternating K... and V... in the same method call. Only one varargs parameter per method call.
The Map interface link I posted shows a way to create entries almost as succinctly as that C# syntax.