if else
IfElse.java1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19public class Test {
public static void main(String args[]){
int x = 30;
if( x == 10 ){
System.out.print("Value of X is 10");
}
else if( x == 20 ){
System.out.print("Value of X is 20");
}
else if( x == 30 ){
System.out.print("Value of X is 30");
}
else{
System.out.print("这是 else 语句");
}
}
}
嵌套的if…else语句
1 | public class Test { |
switch语句
1 | public class Test { |