public class T1 {
public static void main(String[] args) {
T1 t1 = new T1();
T2 t2 = new T2();
//把问题传过去给T2,并且把T1的对象也传过去,因为需要告诉T2,是T1传过来的,然后T2才能根据这个对象回复T1
String question = "1 + 1 = ?";
t2.executeMessage(t1, question);
}
//T2回答的答案
public void solve(String result) {
System.out.println("答案--->" + result);
}
}
============================================================================================
public class T2 {
//T1提出的问题
public void executeMessage(T1 t1, String question){
System.out.println("问题--->" + question);
//把答案传回去给T1
t1.solve("2");
}
}