码迷,mamicode.com
首页 > 其他好文 > 详细

选择结构

时间:2017-09-22 14:08:06      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:使用   stat   void   老师   public   ccf   color   bsp   sys   

一:什么是if结构?

语法1:

public class Demo {

   public static void main (String [] args){

       //语句1;

      //语句二;

      if(条件){

            //语句3;

       }

      //语句4;    

     }

}

 

二:使用if-else选择结构

语法2:

if ( 条件 ) {

   //代码块1

}else {

   //代码块2

}

 

事例2:

public class SimpleIF {

    public static void main (String [] args){

          int score = 91;

          if (Score >=98)  {

               System.out.println("老师说:不错,奖励一个MP4!");

         } else {

                  System.out.println("老师说:惩罚进行编码!");

           }

     }

}

选择结构

标签:使用   stat   void   老师   public   ccf   color   bsp   sys   

原文地址:http://www.cnblogs.com/QiliPING9/p/7574269.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!