switch case break


https://zhidao.baidu.com/question/542504321.html

用法如下:

switch (conditions)
{
     case  ...:
      doSomething();
      break ;
     case  ...:
      doAnotherThing();
      break ;
     default :
      defaultThing();

}


switch起到的作用类似于跳转,满足switch的条件会跳转到对应的case下执行代码。

如果不加break,代码会从那开始执行,一直执行到最后,所以不符合case的语句也会被执行


猜你喜欢

转载自blog.csdn.net/qq_34756209/article/details/79738471
今日推荐