Case1 10.조건문 - switch case문 Switch - case 문 - if elseif else 문을 사용할 때 복잡하고 번거로운 부분을 가독성 좋게 구현 - 비교 조건이 특정 값이나 문자열인 경우 사용 - break 문을 사용하여 각 조건이 만족되면 switch 블럭을 빠져나오도록 함 - 자바 14부터 좀 더 간결해진 표현식이 지원 됨(break 사용하지 않음) 예제) public class SwitchCaseTest { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int month = scanner.nextInt(); int day; switch(month) { case 1: day = 31; break; case 2: day = 28.. 2022. 5. 17. 이전 1 다음