首页 > 其他 > 详细

switch… case 语句的用法

时间:2017-05-13 19:38:13      阅读:250      评论:0      收藏:0      [点我收藏+]

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 语句的用法

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!