if (x < 1) System.out.print(x + " < 1"); else if (x > 1) System.out.print(x + " > 1"); else System.out.print(x + " == 1");
Switch
switch (y) { case 0: System.out.print(y + " is 0"); break; case 1: System.out.print(y + " is 1"); break; default:System.out.print(y + " is something else"); }
三元运算符
x = (x < 0.5) ? 0 : 1;
If x < 0.5
x = 0;
else
x = 1 ;
Java 语法 索引 ----- 条件语句(If Else,Switch),布布扣,bubuko.com
时间: 2024-10-06 00:50:47