欢迎光临散文网 会员登陆 & 注册

咕泡Java百万架构精英领航班A2\/--》ccys1473

2023-07-18 08:48 作者:拆字成诗  | 我要投稿

四、流程控制

1、分支语句

1.1 if-else-if

语法:

if(条件){

当条件为true时,执行大括号内的代码

}else if(条件){

}

补充:

//实例化扫描仪对象

Scanner sc = new Scanner(System.in);

System.out.println("请输入第一个值:");

int a = sc.nextInt();

System.out.println("请输入第二个值:");

int b = sc.nextInt();

System.out.println("求和结果:"+(a+b));

//    String s = sc.next();

//    System.out.println(s);

//    double d = sc.nextDouble();


咕泡Java百万架构精英领航班A2\/--》ccys1473的评论 (共 条)

分享到微博请遵守国家法律