我是學習Java的新手,我做的是Practice-It!問題來幫助我理解語言。練習它! 1.2.3:奇怪
我被困在問題1.2.3上,名爲「奇怪」,在這個問題中,他們希望你輸出基於他們提供的代碼的輸出。
我的問題是,我不明白與輸入相比的輸出。
public class Strange {
public static void main(String[] args) {
first();
third();
second();
third();
}
public static void first() {
System.out.println("Inside first method.");
}
public static void second() {
System.out.println("Inside second method.");
first();
}
public static void third() {
System.out.println("Inside third method.");
first();
second();
}
}
我想輸出將是:
Inside first method.
Inside third method.
Inside first method.
Inside second method.
Inside second method.
Inside first method.
Inside third method.
Inside first method.
Inside second method.
但它是:
Inside first method.
Inside third method.
Inside first method.
Inside second method.
Inside first method.
Inside second method.
Inside first method.
Inside third method.
Inside first method.
Inside second method.
Inside first method.
這是爲什麼?
非常感謝。
只需按照您的代碼並再次檢查。你認爲是錯的。 – Chen