https://opentutorials.org/course/3975/26779
조건문 - 생활코딩
수업소개 조건에 따라서 다르게 동작하게 프로그램을 디자인하는 핵심은 조건문입니다. 조건문이라는 위대한 도구를 이용해서 우리의 프로그램을 더욱 지능적으로 만들어봅시다. 강의1 소스
opentutorials.org
public class IfApp {
public static void main(String[] args) {
System.out.println("a");
if(false) {
System.out.println(1);
}
System.out.println("b");
}
}
영원히 실행될 수 없는 코드 (if문의 조건에 false가 들어가는 문장) = dead코드라 오류 밑줄이 뜬다.
단일 블럭 ctrl + /
블럭 주석 ctrl + shift + /
public class IfApp {
public static void main(String[] args) {
System.out.println("a");
// if(false) {
// System.out.println(1);
// } else {
// if(true) {
// System.out.println(2);
// }
// else{
// System.out.println(3);
// }
// }
if(false) {
System.out.println(1);
} else if (true) {
System.out.println(2);
}
else{
System.out.println(3);
}
System.out.println("b");
}
}
'JAVA' 카테고리의 다른 글
[생활코딩] 제어문 - 문자의 비교 : ==과 equals의 차이점 (0) | 2024.07.02 |
---|---|
[생활코딩] 제어문 - boolean (0) | 2024.07.02 |
[JAVA] 입력과 출력 (0) | 2024.07.01 |
[생활코딩] 디버거 (0) | 2024.07.01 |
[생활코딩] 프로그래밍이란? (0) | 2024.07.01 |