Use hashtables. Where each key points an element like your months. Maybe you can build your own hash function too. Could be O(1) access time rather than O(n).
Hashtable numbers = new Hashtable();
numbers.put("one", new Integer(1)); //String<-->Integer
numbers.put("two", new Integer(2));
numbers.put("three", new Integer(3));
Integer n = (Integer)numbers.get("two");
if (n != null) {
System.out.println("two = " + n);
}
You can change the key and element(in this example they are String and Integer) like this:
Hashtable<Integer, String> abc=new Hashtable<Integer, String>();
abc.put(new Integer(4), "hello");
Hashtables accept object for both key and item so you can use any class that extends Object. Very flexible. But, playing with object could decrease performance a bit, since you are not saying about anything like a "benchmark" , this could be your friend.
__________________________________________________________
| You can use Integer.valueOf() (available since Java 1.5) |
| instead of new Integer Credit to "Steve Kuo" |