I need to pass the ordinal value of an enum as a parameter to a HashMap<String, String>. In other words, I want to cast an ordinal as a String.
Right now, I'm doing this:
HashMap<String, String> myHashMap = new HashMap<String, String>();
myHashMap.put("foo", String.format("%s", MyEnum.BAR.ordinal()));
Is that the best way? The .toString() method isn't available here, and (String)MyEnum.BAR.ordinal() doesn't work.
Map<String, MyEnum>.