* Initialization safety for immutable objects
*
* @author Brian Goetz and Tim Peierls
*/
@ThreadSafe
public class SafeStates {
private final Map states;
public SafeStates() {
states = new HashMap();
states.put("alaska", "AK");
states.put("alabama", "AL");
/*...*/
states.put("wyoming", "WY");
}
public String getAbbreviation(String s) {
return states.get(s);
}
}