I'd like to create a map or hash-map (or something similar) that looks something like this:
Map < string, ? > items = new Map < string, ?>();
items.put("string" , classObject);
items.put("string2" , classObjectOfDifferentType);
items.put("string3" , classObjectOfAnotherType);
The idea is to create something of a static look up table that will contain objects of unique class types as values. I'll pass in a string and return the object I want.
I tried creating a map like this:
private final String STRINGVALUE = "STRINGVALUE";
private Map<String, Object> handlers = new HashMap<String, Object>();
private static StringHandler STRING_HANDLER;
//creation of StringHandler using the Spring framework here
handlers.put(STRINGVALUE, STRING_HANDLER);
I'm getting a strange, unhelpful error, though, on the parentheses of the 'put' call.
So what's the right way to do this?
edit:
errors are: "syntax error on )" "syntax error on ("
Stringfromstring, and share error