嗨我有字符串值的Map.
我想在运行时强制转换此值.
例如
Map map = new HashMap();
map.put("key1","101");
map.put("key2","45.40");
Run Code Online (Sandbox Code Playgroud)
现在运行时我知道key1是整数而key2是double我该如何转换它.
我试过这个:
("101").getClass().cast(Integer).
Run Code Online (Sandbox Code Playgroud)
////////////////////////////////////////////// ........
String integerClass ="java.lang.Integer"; String strNum ="5"; 现在,您将如何使用integerClass将此strNum值"5"转换为Integer.
.....不直接使用新的Integer(strNum)
谢谢.
如果打开多个窗口,这应该有效.
我的应用程序是在J2EE中.
我已经在window.unloadn上尝试了一些javascript,但这种解决方案并不牢固.