私は Java を学ぶのが初めてで、Practice-It! を行っています。言語を理解するのに役立つ質問。
Strange というタイトルの問題 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.
どうしてこれなの?
どうもありがとう。