package callback;
class Boss{
public void call(Worker worker){
String detail="finish this";
worker.work(detail);
}
}
interface Worker{
abstract void work(String str);
}
public class Test {
public static void main(String[] args) {
Boss boss=new Boss();
boss.call(
new Worker(){
public void work(String str){
System.out.println("I have to "+str);
}
}
);
}
}
07-12
14万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-18
07-18
07-18
07-18
07-18
07-18
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交