Published in


How to initialize a static Map using Eclipse Collections

Initializing a Map using Eclipse Collections is simple and flexible.

Using the object and primitive Map factories

I answered the following question on Stack Overflow almost a decade ago.

If you create a MutableMap in Eclipse Collections using empty and withKeyValue, you can then chain as many key / value combinations as you need. As a final conversion step, you can make the Map synchronized (asSynchronized), unmodifiable (asUnmodifiable) or immutable (toImmutable).

Using empty, withKeyValue, asUnmodifiable, and toImmutable to create Maps

I show more examples of creating Maps, Lists, Sets, and Bags fluently using Eclipse Collections in the following blog.

Thanks for reading! Enjoy!

I am the creator of and a Committer for the Eclipse Collections OSS project which is managed at the Eclipse Foundation. Eclipse Collections is open for contributions.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Donald Raab

Donald Raab

Java Champion. Creator of the Eclipse Collections OSS Java library ( Inspired by Smalltalk. Opinions are my own.