This question is in continuation with Java: Using Classes as a value in hashmap.
What is the difference between following two approaches?:
1)
String name = (
(
CustomClass1
)obj1
).getName();
and 2)
String name = (
(
mapQuery2ResponseType.get("string1")
)obj1
).getName();
where, mapQuery2ResponseType.get("string1")
return value of type Class<?>
First approach works perfectly but in second approach it's giving an error saying Syntax error on token "obj1", delete this token
.
How can I modify second approach (Using Map) so as to work as in first case?
How can I make mapQuery2ResponseType.get("string1")
to return CustomClass1
instead of CustomClass1.class
?