# 第1章. 故事的缘起

public class Student
{
private String name = null;

public Student(String name)
{
// TODO Auto-generated constructor stub
this.name = name;
}

public void setName(String name)
{
this.name = name;
}

private int calcADD(int a, int b)
{
return a + b;
}

public void fillBlank(int a, int b)
{
System.out.println(name + "心算:" + a + " + " + b + " = " + result);
}
}

public class Test
{
public static void main(String[] args)
{
int a = 1;
int b = 1;
Student s = new Student("小明");
s.fillBlank(a, b);
}
}

小明心算:1 + 1 = 2

# 第2章. 幼师的找茬

public class Calculator
{
public int add(int a, int b)
{
return a + b;
}
}

public class Student
{
private String name = null;

public Student(String name)
{
// TODO Auto-generated constructor stub
this.name = name;
}

public void setName(String name)
{
this.name = name;
}

@SuppressWarnings("unused")
private int calcADD(int a, int b)
{
return a + b;
}

private int useCalculator(int a, int b)
{
}

public void fillBlank(int a, int b)
{
int result = useCalculator(a, b);
System.out.println(name + "使用计算器:" + a + " + " + b + " = " + result);
}
}

public class Test
{
public static void main(String[] args)
{
int a = 168;
int b = 291;
Student s = new Student("小明");
s.fillBlank(a, b);
}
}

# 3.幼师回来了

public class SuperCalculator
{
public void add(int a, int b, Student  xiaoming)
{
int result = a + b;
xiaoming.fillBlank(a, b, result);
}
}

public class Student
{
private String name = null;

public Student(String name)
{
// TODO Auto-generated constructor stub
this.name = name;
}

public void setName(String name)
{
this.name = name;
}

public void callHelp (int a, int b)
{
}

public void fillBlank(int a, int b, int result)
{
System.out.println(name + "求助小红计算:" + a + " + " + b + " = " + result);
}
}

public class Test
{
public static void main(String[] args)
{
int a = 26549;
int b = 16487;
Student s = new Student("小明");
s.callHelp(a, b);
}
}

小明求助小红计算:26549 + 16487 = 43036

# 第4章. 门口的婆婆

public interface doJob
{
public void fillBlank(int a, int b, int result);
}

public class SuperCalculator
{
public void add(int a, int b, doJob  customer)
{
int result = a + b;
customer.fillBlank(a, b, result);
}
}

/**
* Java学习交流QQ群：589809992 我们一起学Java！
*/
public class Student
{
private String name = null;

public Student(String name)
{
// TODO Auto-generated constructor stub
this.name = name;
}

public void setName(String name)
{
this.name = name;
}

public class doHomeWork implements doJob
{

@Override
public void fillBlank(int a, int b, int result)
{
// TODO Auto-generated method stub
System.out.println(name + "求助小红计算:" + a + " + " + b + " = " + result);
}

}

public void callHelp (int a, int b)
{
}
}

/**
* Java学习交流QQ群：589809992 我们一起学Java！
*/
public class Seller
{
private String name = null;

public Seller(String name)
{
// TODO Auto-generated constructor stub
this.name = name;
}

public void setName(String name)
{
this.name = name;
}

public class doHomeWork implements doJob
{

@Override
public void fillBlank(int a, int b, int result)
{
// TODO Auto-generated method stub
System.out.println(name + "求助小红算账:" + a + " + " + b + " = " + result + "元");
}

}

public void callHelp (int a, int b)
{
}
}

public class Test
{
public static void main(String[] args)
{
int a = 56;
int b = 31;
int c = 26497;
int d = 11256;
Student s1 = new Student("小明");
Seller s2 = new Seller("老婆婆");

s1.callHelp(a, b);
s2.callHelp(c, d);
}
}

小明求助小红计算:56 + 31 = 87

# 最后的话

#### JAVA回调机制(CallBack) 趣解

2017-05-26 15:06:02

#### 详解Java回调机制 (Callback) 讲解+实例

2015-09-02 15:45:21

#### java回调机制及其实现

2014-05-21 11:02:10

#### Java、Android中的回调（callBack）我写的一个网络回调大家可以参考参考

2015-02-11 14:44:45

#### Listener 和 Callback

2017-02-27 20:44:19

#### openstack nova 基础知识——rpc回调机制(callback)

2012-08-21 02:47:14

#### anroid 学习之java回调机制与自定义接口回调方法的使用

2015-03-20 14:25:34

#### spring对hibernate的集成中的回调（CallBack）机制

2017-02-02 20:33:32

#### 弄明白Android 接口回调机制

2014-12-30 13:15:07

#### 什么是回调机制(Call back)

2016-10-28 18:04:23