You can create a template Map, and use .clone() to generate new instances. You could also create a custom Map implementation that uses a copy-on-write policy to refer to a template "parent" Map.
initialize non-static hashmap with standard keys in java
-
30-07-2022 - |
Pregunta
Am looking for an efficient way to initialize a HashMap given that it's keys remain the same for any object created of the class it belongs to.
My current implementation initializes the HashMap everytime a new class object is created.
Thanks!
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow