如何能够通过字符串动态构造Integer对象?? (1)用Class.forName("类名").newInstance()动态创建对象(2)用Integer.parseInt(String)从字符串中获得整数值 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 String strValue = "25";Integer intObj = new Integer(strValue); public static void main(String[] args) throws Exception{ String strType="java.lang.Integer",strValue="25"; Class cls=Class.forName(strType); java.lang.reflect.Constructor cst=cls.getConstructor(new Class[]{String.class}); Object obj=cst.newInstance(new Object[]{strValue}); System.out.println(obj);} stop !已得高人指点,强人多压,可惜不再csdn上 抱歉抱歉,没看到 flyforlove(为情飞) 的回复,我还以为没人理我呢。方法可行。 各位大哥、大姐。高手们 都进来来帮帮忙吧、 小弟感激不尽。 session和cookie的问题 求救。找不到路径 web.xml文件錯誤 各位大侠,请问这是JB9的问题还是我的代码有问题,还是JB9没配置好?? JSP连不上SQL Server。请大虾们帮忙呀! 高分求教 有把JSP文件转换成WML格式的工具吗? 消息触发的问题300分,另外200开帖加! {{each cardlist as value i}}...{{/each}} 这属于什么语言? 请问STRUCTS如何实现动态表单的功能? 在eclipse启动tomcat的问题
Integer intObj = new Integer(strValue);
String strType="java.lang.Integer",strValue="25";
Class cls=Class.forName(strType);
java.lang.reflect.Constructor cst=cls.getConstructor(new Class[]{String.class});
Object obj=cst.newInstance(new Object[]{strValue});
System.out.println(obj);
}