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

switch… case 语句的用法

时间:2017-05-13 20:09:57      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:oid   bsp   nbsp   结果   system   用法   one   stat   class   

public class Test7
{
     public static void main(String[] args)
     {
        int i=5;
        switch(i)
        {
              case 1:
               System.out.println("one");
              case 10:
               System.out.println("ten");
              case 5:
               System.out.println("five");   
              case 3:
               System.out.println("three");
              default:
               System.out.println("other");
        }
    }
}
复制代码
è 结果是:

five
three
other
 
复制代码
switch(表达式)

{

case 常量表达式1:语句1;

....

case 常量表达式2:语句2;

default:语句;

}

switch… case 语句的用法

标签:oid   bsp   nbsp   结果   system   用法   one   stat   class   

原文地址:http://www.cnblogs.com/RAOZHAOYANG/p/6849876.html

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