Demo07.java 962 B

123456789101112131415161718192021222324252627282930313233343536
  1. package com.loveCoding.j20250426_java_basic;
  2. /**
  3. * @author WanJl
  4. * @version 1.0
  5. * @title Demo07
  6. * @description
  7. * @create 2025/4/26
  8. */
  9. public class Demo07 {
  10. public static void main(String[] args) {
  11. int a=1;
  12. switch (a){
  13. case 1:
  14. System.out.println("a是1");
  15. break; //作用是结束switch语句
  16. case 2:
  17. System.out.println("a是2");
  18. break;
  19. case 3:
  20. System.out.println("a是3");
  21. break;
  22. case 4:
  23. System.out.println("a是4");
  24. break;
  25. case 5:
  26. System.out.println("a是5");
  27. break;
  28. case 6:
  29. System.out.println("a是6");
  30. break;
  31. default: //如果以上条件都不满足,就执行default
  32. System.out.println("我也不知道是多少");
  33. }
  34. }
  35. }