public AB class{

private  CD cd;
private String ef;
private Date gh;
//init将变量挂到一个地方,以后的方法中多次调用
public void init(CD cd){
 ef = cd.getXX();
gh = cd.getXX();
}

public void methodA(){
 anotherMethod(ef,gh);
}

public void methodB(){
 theOtherMethod(ef,gh);
}


}

以后在用到的时候

步骤1:new 一个类set变量
CD cd = new CD();
cd.setXX();
步骤2:AB对象调用cd
AB.init(cd);
步骤3:AB的对象调用methodA
AB.methodA();

 

相关文章:

  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2021-04-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案