public class ClassA{
private long Rkey;
public long getRkey() {
return Rkey;
}
public void setRkey(long rkey) {
this.Rkey = rkey;
}
}
public class ClassA{
private long Rkey;
public long getRkey() {
return Rkey;
}
public void setRkey(long rkey) {
this.Rkey = rkey;
}
}
-----------------------------
public class Assistant {
public static final String CLASSA= "classA";
public static Object create(String str) {////////////返射机制的方法
Object cf=null;
try {
cf = (Object)Class.forName(str).newInstance();
}
catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
catch (IllegalAccessException ex) {
ex.printStackTrace();
}
catch (InstantiationException ex) {
ex.printStackTrace();
}
return cf;
}
调用:
classA cc=(classA)Assistant.create(Assistant.CLASSA);
cc.setRkey(rkey);
cc.getRkey();
posted on 2006-04-14 16:14
有猫相伴的日子 阅读(353)
评论(0) 编辑 收藏 所属分类:
j2ee