Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Directly Initialize a HashMap in Java

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

The following code snippet in Java 9+ initialize an immutable HashMap with up to 10 elements.

{c=d, a=b}

The following code snippet in Java 9+ initialize an immutable HashMap with arbitrary number of elements.

{c=d, a=b}