我对输出感到困惑(即showValue
在类中的方法之后Mno
)
class Lab2 {
public static void main(String[] aa) {
int ab=98;
System.out.println("ab in main before\t:"+ab);
Mno ref = new Mno();
ref.showValue(ab);
System.out.println("ab in Main After\t:"+ab);
}
}
class Mno {
void showValue(int ab) {
System.out.println("ab in showvalue before\t:"+ab);
if (ab!=0)
showValue(ab/10);
System.out.println("ab in showvalue After\t:"+ab);
}
}
我得到以下输出......它如何在 0,9,98 之后打印显示值......?
F:\Train\oops>java Lab2
ab in main before :98
ab in showvalue before :98
ab in showvalue before :9
ab in showvalue before :0
ab in showvalue After :0
ab in showvalue After :9
ab in showvalue After :98
ab in Main After :98