Runtime casting from String to other datatype
Posted
by Gengrlin
on Stack Overflow
See other posts from Stack Overflow
or by Gengrlin
Published on 2010-05-17T03:49:30Z
Indexed on
2010/05/17
4:00 UTC
Read the original article
Hit count: 156
java
Hi I have Map of String values.
I want to cast this value at runtime.
e.g.
Map map = new HashMap();
map.put("key1","101");
map.put("key2","45.40");
Now runtime I know key1 is integer and key2 is double How can I cast this.
I tried this:
("101").getClass().cast(Integer).
Thanks.
© Stack Overflow or respective owner