switch
-
[JAVA] switch문언어/JAVA 2022. 9. 7. 17:18
-if문과 비슷한 구조이지만 변수값의 단순 참조에 의해 실행될 명령이 선택되는 것이 다름 -switch문 괄호 안의 a변수 값을 참조하여 해당 값이 있는 case의 명령을 실행함 -break: 자신을 감싸고 있는 if문 또는 반복문의 경계 ( { } )를 빠져나가라는 명령 요일 구하기 canner sc=new Scanner(System.in); System.out.printf("Month: "); int m=sc.nextInt(); System.out.printf("Day: "); int d=sc.nextInt(); int days=0; switch(m) { case 12: days=days+30; case 11: days=days+31; case 10: days=days+30; case 9: days=..