How to create a Map of more than 10 entries in Java

Introduction

Java Map has a static initializer of(), which creates an Immutable Map Collection

You can create up to 10 Elements in this Map

For example

Java

What do to for more than 10 entries?

Now if you want to add key11 and value11, what can you do?

Unfortunately, you cannot just a simple Map.of() method anymore, rather use Map.ofEntries()

This method doesn’t have a hard cap.

Java

If you found another method, let me know in the comments below 🙂

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Nach oben scrollen