F
Frank Fredstone
What is the right way to create a map from Strings to arbitrary and
diverse objects? For example, so I can have:
map.put("a", "text");
map.put("b", new Integer(2));
etc. where the value needs to be able to be any sub-class of Object.
I read in a generics FAQ:
http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html
about creating a collection containing objects like Pair<K, ?>, and
presumably I could implement a class that behaves like a Map but uses
a collection of pairs with an unbounded value, but I would think this
would be a pretty common thing and there might be an easier way to do
that. Ideas?
diverse objects? For example, so I can have:
map.put("a", "text");
map.put("b", new Integer(2));
etc. where the value needs to be able to be any sub-class of Object.
I read in a generics FAQ:
http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html
about creating a collection containing objects like Pair<K, ?>, and
presumably I could implement a class that behaves like a Map but uses
a collection of pairs with an unbounded value, but I would think this
would be a pretty common thing and there might be an easier way to do
that. Ideas?