I have a simple integer mapping in Java, but I need to be able to easily extract a string from an integer, as well as an integer from a string. I tried Map, but it can only extract a string from an integer, this is one way:
private static final Map<Integer, String> myMap = new HashMap<Integer, String>();
Is there a right way to do this for both directions?
Another problem is that I have only a few constant values ββthat do not change ( 1->"low", 2->"mid", 3->"high" , so it would not be worth going to a difficult decision.
java apache-commons guava map
Danijel May 22 '12 at 9:42 a.m. 2012-05-22 09:42
source share