I have a method which accepts two values and converts it into key-value pair of a map and returns it to the calling method. The key is always String but the value can be of any Class. I can't seem to convert the value into generic while accepting in method signature. Here's my code:
private Map<String, Class<T>> mapBuilder(String key, T value) {
Map<String, Class <T>> map = new HashMap<>();
map.put(key, value);
return map;
}
Can someone tell what can be done instead?
String key, Class<T> valueas the method params and call this method invoking.classon the params before passing them to the method?