관리 메뉴

nalaolla

Switch~Case~Break 본문

JAVA/3. Control

Switch~Case~Break

날아올라↗↗ 2015. 12. 20. 16:49
728x90
  1. package test.com;
  2.  
  3. public class Test06SwitchCaseBreak {
  4.  
  5.     public static void main(String[] args) {
  6.         // TODO Auto-generated method stub
  7.         System.out.println("switch ~ case ~ default ~ break;");
  8.  
  9.         // 정수비교
  10.         int x = 100;
  11.        
  12.         switch (x) {
  13.         case 100 :
  14.             System.out.println("A++");
  15.            
  16.             boolean bool = false;
  17.             if(bool = x%2 == 0) {
  18.                 System.out.println("짝수");
  19.             }
  20.            
  21.             System.out.println(bool);
  22.            
  23.             break//if문의 블럭을 제외한 가장 가까운 블럭의 끝을 빠져나가라.
  24.         case 90 :
  25.             System.out.println("A");
  26.             break;
  27.         case 80 :
  28.             System.out.println("B");
  29.             break;
  30.         default :
  31.             System.out.println("Other");
  32.         }
  33.     }
  34.  
  35. }


728x90

'JAVA > 3. Control' 카테고리의 다른 글

switch~case~break 성적관리 예제  (0) 2015.12.20
Switch~Case~Break 예제2  (0) 2015.12.20
자바는 블럭단위 처리다.  (0) 2015.12.20
if~else GAME2  (0) 2015.12.20
if~else game  (0) 2015.12.20