java模拟接口回调
2016-05-19 20:51
489 查看
public class Test {
public static void main(String[] args) {
InterfaceReturn interfaceReturn=new InterfaceReturn();
interfaceReturn.setonclick(new InterfaceReturn.MyInterface() {
@Override
public void onclick(int position) {
// TODO Auto-generated method stub
System.out.println(this);
}
});
}
}
public class InterfaceReturn{
MyInterface myInterface;
public void setonclick(MyInterface i){
myInterface=i;
}
public void loading(){
if(null != myInterface)
myInterface.onclick(0);
System.out.println("InterfaceReturn------------->"+this);
}
public interface MyInterface{
public void onclick(int position);
}
}
public static void main(String[] args) {
InterfaceReturn interfaceReturn=new InterfaceReturn();
interfaceReturn.setonclick(new InterfaceReturn.MyInterface() {
@Override
public void onclick(int position) {
// TODO Auto-generated method stub
System.out.println(this);
}
});
}
}
public class InterfaceReturn{
MyInterface myInterface;
public void setonclick(MyInterface i){
myInterface=i;
}
public void loading(){
if(null != myInterface)
myInterface.onclick(0);
System.out.println("InterfaceReturn------------->"+this);
}
public interface MyInterface{
public void onclick(int position);
}
}
相关文章推荐
- java读写ini文件、FileOutputStream
- JAVA 大整数类
- Java 集合小结
- java之stream(jdk8)
- 个人对Spring @Scope("prototype")的一些理解
- M进制与N进制之间的转换
- JAVA设计模式(18):行为型-状态模式(State)
- eclipse中java连接mysql数据库
- maven项目 启动报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- Spring
- 利用java实现二叉树以及非递归遍历算法
- JAVA设计模式(17):行为型-模板方法模式(Template Method)
- 【Java基础】语言基础知识
- 《JAVA:异常的处理》NumberFormatException异常
- access denied ("java.util.PropertyPermission" "*" "read,write")
- spring中乱码问题总结
- eclipse failed to create the java virtual machine
- java工程目录
- Java成长笔记-----垃圾回收机制
- Hibernate中的多对多关联