How can I initialise a static Map?

前端 未结 30 1654
慢半拍i
慢半拍i 2020-11-22 08:43

How would you initialise a static Map in Java?

Method one: static initialiser
Method two: instance initialiser (anonymous subclass) or some other m

30条回答
  •  旧巷少年郎
    2020-11-22 09:25

    Maybe it's interesting to check out Google Collections, e.g. the videos that they have on their page. They provide various ways to initialize maps and sets, and provide immutable collections as well.

    Update: This library is now named Guava.

提交回复
热议问题