public class ExampleClass {
public final static HashMap consts = new HashMap();
static{
constants.put("A", "The Letter A");
constants.put("B", "The Letter B");
constants.put("C", "The Letter C");
}
/* Rest of your class that needs to know the consts */
}
A simple example of how to initialize a static hash map in java
静态HashMap 初始化填充
最新推荐文章于 2024-09-09 09:15:52 发布