1. String name = "com.xxx.xxx.xxx"; // make sure this is right
2. Object o = Class.forName(name).getDeclaredConstructor(
new Class[]{
// depends on your construct parameter list
// This is the example for xxx(Integer x, int y)
Class.forName("java.lang.Integer"),
Integer.TYPE
}).newInstance(
new Object[]{
new Integer("333333"),
new Integer("22")});
3. if (o instance of com.xxx.xxx.xxx) {
((com.xxx.xxx.xxx)o).doSomething(...);
}
2. Object o = Class.forName(name).getDeclaredConstructor(
new Class[]{
// depends on your construct parameter list
// This is the example for xxx(Integer x, int y)
Class.forName("java.lang.Integer"),
Integer.TYPE
}).newInstance(
new Object[]{
new Integer("333333"),
new Integer("22")});
3. if (o instance of com.xxx.xxx.xxx) {
((com.xxx.xxx.xxx)o).doSomething(...);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货