Declaring and initializing a static hashmap
| In Brief | A simple example of how to initialize a static hash map in java |
| Language | Java |
# 's
1public class ExampleClass {
2 public final static HashMap consts = new HashMap();
3 static
4 {
5 constants.put("A", "The Letter A");
6 constants.put("B", "The Letter B");
7 constants.put("C", "The Letter C");
8 }
9 /* Rest of your class that needs to know the consts */
10}
A simple example of how to initialize a static hash map in java
Add a Comment