我想传递类之间的一些信息,如成功或失败,失败的原因,缺失的数据等 但我不知道哪个是正确的方式来做到这一点。此外,我无法将信息作为参数传递,因为我需要将其恢复。由于已有返回值,因此无法返回任何值。 例如:假设我有类这样的(它只是哑代码的实际代码很长)如何在对象之间传递数据
class A {
B b = new B();
C c = new C();
b.putData();
c.putData();
//Want to print all the inforamtion of what happend
//in methods of putData and getData. How to do that?
}
class B {
boolean putData() {
D d = new D();
Data data =d.getData();
//some code goes here
}
}
Class C{
boolean putData() {
//some code here
}
}
传递一个对象作为参数? – jean
'想要以最简单的方式为您感兴趣的值添加System.out.println(...)'语句,打印putData和getData.'方法中发生的所有事件的信息。更好的方法:更改你的问题要清楚你想要达到什么目的。 – SubOptimal
对不起,我忘记提及我无法传递参数,因为我必须将其恢复,这是我无法完成的,因为所有方法都已返回一些对象。 – ABYS