也不知道我理解的对不对,欢迎大家讨论!

自己写了个钩子函数,我理解的钩子函数:

public interface Transactioner {

String wedontknow() ;</br></br>

}


public abstract class GouZi  {

<span style="color:#000080;font-weight:bold;">public abstract void </span><span style="background-color:#e4e4ff;">gouzi</span>(Transactioner t);</br></br>

}

public class Test extends GouZi{

public static void main(String []s){
Test t = new Test();
t.gouzi(new Transactioner() {
@Override
public String wedontknow() {
return "this is from Transactioner---wedontknow";
}
});
}

@Override
public void gouzi(Transactioner t) {
System.out.println("This is from gouzi function");
System.out.print(t.wedontknow());
}
}

=============== 运行结果:
This is from gouzi function
this is from Transactioner---wedontknow



相关文章:

  • 2021-11-02
  • 2021-10-27
  • 2021-10-04
  • 2021-09-08
猜你喜欢
  • 2021-03-31
  • 2022-12-23
  • 2021-08-05
  • 2021-12-04
  • 2022-01-10
  • 2021-08-15
  • 2021-04-09
相关资源
相似解决方案