public class Demo01IfElseExt {
public static void main(String[] args){
int x = -10;
int y;if(x >= 3){
y = 2 * x + 1;}elseif(-1 < x && x < 3){
y = 2 * x;}else{
y = 2 * x -1;}
System.out.println("结果是:" + y);}}
public class Demo03Max {
public static void main(String[] args){
int a = 105;
int b = 20;
// 使用三元运算符
// int max = a > b ? a : b;
// 使用if语句
int max;if(a > b){
max = a;}else{
max = b;}
System.out.println("最大值:" + max);}}
if-else语句练习练习一x和y的关系满足如下:如果x >= 3,那么y = 2x +1;如果-1 < x < 3,那么y = 2x;如果x <= -1,那么y = 2x -1。public class Demo01IfElseExt { public static void main(String[] args) { int x = -10; int y; if (x >= 3) { y = 2 * x + 1; } else if (-