- Multiple ifs are executed regardless of whether you are in front of ture or not
- else if if one of the former is true, then none of the latter are executed
public class Test {
public static void main(String[] args) {
int a = 1;
if (a == 1) {
System.out.println("1");
}
if (a == 2) {
System.out.println("2");
}
if (a == 3) {
System.out.println("3");
}
if (a == 1) {
System.out.println("1");
} else if (a == 2) {
System.out.println("2");
} else if (a == 3) {
System.out.println("3");
} else if (a == 4) {
System.out.println("4");
}
}
}
The level is limited, if you have any questions, please leave a message to exchange.
Learn from each other and make progress together :) Please indicate the source for reprinting. Thank you.