What is the most straightforward way to create a hash table (or associative array...) in Java? My google-fu has turned up a couple examples, but is there a standard way to do t
You can use double-braces to set up the data. You still call add, or put, but it's less ugly:
private static final Hashtable MYHASH = new Hashtable() {{ put("foo", 1); put("bar", 256); put("data", 3); put("moredata", 27); put("hello", 32); put("world", 65536); }};