newIncetance()怎样可以实例化带参数的构造器? 反射这块还是不太清楚? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://topic.csdn.net/u/20080404/10/fd572e31-24bf-4472-b994-66ed1636ba3b.html78楼我有例子。 Java codepublic class TestClass { private int testInteger; private String testString; public TestClass(Integer testInt, String testStr) { this.testInteger = testInt.intValue(); this.testString = testStr; }}...try { Class classTestClass = Class.forName("TestClass"); Class[] types = new Class[] {Integer.class, String.class}; Constructor constructor = classTestClass.getConstructor(types); Object[] args = new Object[] {123, "abc"}; Object testClass = constructor.newInstance(args);} catch (Exception e) { e.printStackTrace();} JTextField 失去焦点的问题 不用循环~如何输出1~100? 收集java的常用函数代码!大家分享,共同学习!请分享者到此接分[续二]! 怎么判断一个输入数串是DOUBLE 还是int啊? 我的注册码为什么产生不出来 高手解决下 eclipse中输入小写类名,弹出的那个错误提示框如何实现,哪位大大知道帮帮忙,在线等 如何使我的实例必须执行某个方法. jsp数据库驱动问题 如何引入jdbc.sql.* ,高分相送啊 请问各位JAVA高手,都用JAVA开发过什么项目? 关于监听生成文本框的问题~ 请教一个关于继承的问题
private int testInteger;
private String testString;
public TestClass(Integer testInt, String testStr) {
this.testInteger = testInt.intValue();
this.testString = testStr;
}
}...try {
Class classTestClass = Class.forName("TestClass");
Class[] types = new Class[] {Integer.class, String.class};
Constructor constructor = classTestClass.getConstructor(types);
Object[] args = new Object[] {123, "abc"};
Object testClass = constructor.newInstance(args);
} catch (Exception e) {
e.printStackTrace();
}