if ステートメントと整数の定義について質問があります。このコードでは:
if(matches!=null) {t =1;
for (String match : matches) {
if (t == 1 && "one".equals(match)) {
testSound.start();
t = 2;
System.out.println("the value of t is" + t);
} else if (t == 2 && "two".equals(match)) {
testSound.start();
t = 3;
System.out.println("the value of t is" + t);
}
}
最初の if ステートメントが実行されて 2 が返され、次に match = "two" が返された場合、else if ステートメントは機能しますか? そうでない場合、t = 2 に設定すると、実際には t = 2 になるようにするにはどうすればよいでしょうか。今はうまくいかないので教えてください!