本站不再更新,欢迎光临 java开发技术网
随笔-230  评论-230  文章-8  trackbacks-0

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 有猫相伴的日子 阅读(346) 评论(0)  编辑  收藏 所属分类: j2ee

只有注册用户登录后才能发表评论。


网站导航:
 
本站不再更新,欢迎光临 java开发技术网