java switch

switch 中break使用,删除break看输出效果。

public static void main(String[] args) {
        for(int i =1;i<=100;i++){
            
            System.out.println("i="+i);
            switch(i){
              case 1:
                  System.out.println("the case 1");
                  break;
              case 2:
                  System.out.println("the case 2");
                  break;
              case 3:
                  System.out.println("the case 3");
            }
        }
        
        System.out.println("main method done");
        
        
    }

 

posted @ 2018-06-03 20:17  newlangwen  阅读(114)  评论(0编辑  收藏  举报