Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preserve ordering with immutable Map?

When using java.util.Map.of(), it does not preserve ordering. Is there a way to have immutable Map which does preserve ordering?

like image 562
nimo23 Avatar asked Sep 19 '19 22:09

nimo23


1 Answers

I believe what you are looking for is LinkedHashMap. Linked Hashmap is a like a regular HashMap that preserves insertion order.

like image 186
randypaq13 Avatar answered Sep 20 '22 22:09

randypaq13