P
Purush
Hi,
Let us say, I have a static method as follows:
static <T> getData(Class<T> cls, String name) {
...
return cls.cast(..);
}
I would like to call the above method like:
Map<String, Integer> data = getData(Class<Map<String, Integer>>,
"name")
or
Map<String, Integer> data = getData(Map<String, Integer>.class,
"name")
and avoid all compiler warnings. But, the compiler does not accept
both.
Did any one run into this and know of a way to get this working?
Thanks
Purush
Let us say, I have a static method as follows:
static <T> getData(Class<T> cls, String name) {
...
return cls.cast(..);
}
I would like to call the above method like:
Map<String, Integer> data = getData(Class<Map<String, Integer>>,
"name")
or
Map<String, Integer> data = getData(Map<String, Integer>.class,
"name")
and avoid all compiler warnings. But, the compiler does not accept
both.
Did any one run into this and know of a way to get this working?
Thanks
Purush