分享

Day2 第八个知识点

 短腿鲁班代码记 2019-09-17

public class Test

{

public static void main(String arfs[])

{

      int i=1;

  switch(i)

{

  case 0:

  System.out.println("zero");

  case 1:

  System.out.println("one");

  case 3:

  System.out.peintln("three");

  default://上面都那不行就是这个

  System.out.println("four");

  }

  //String使用举例子

  String season="SPRING";

  switch(season)

{

  case "SPRING":

  System.out.println("春天");

      break;

  case "SUMMER":

  System.out.println("夏天");

      break;

      case "WINTER":

  System.out.println("冬天");

      break;

case "AUTOM":

  System.out.println("秋天");

      break;

default:

System.out.println("输入有误");

    break;

  }

}

}

/*

switch(变量){根据变量的值与case值进行匹配

case 常量1:

语句1;

break;

case 常量2:

语句2;

break;

… …

case 常量N:

语句N;

break;

default://可以放在任何位置 

语句;

break;//这个最好也加上

}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多