I need to convert full state name to its official state address code. For example from the String New York, I need to produce NY. Now I could put this all in a hashmap, bu
I think the simplest way would be with a HashMap. Even if there was a library to convert it, it would probably use the same thing.
Map states = new HashMap();
states.put("Arizona", "AZ");
states.put("California", "CA");
// So on and so forth...
// Then you could create a method like
public String toStateCode(String s) {
return states.get(s);
}