License Public Domain
Lines 10
Keywords
hash (1) hashmap (1) java (9) map (2) newbie (3)
Included in this Library
Permissions
Group Owner: Java Basics
Viewable by Everyone
Editable by All Siafoo Users
Hide
Easily highlight source code for your blog with our Syntax Highlighter. Join Siafoo Now or Learn More

Declaring and initializing a static hashmap Atom Feed 0

In Brief A simple example of how to initialize a static hash map in 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