중급 Java
Jim White
Java Developer
조건이 true이면 ✅ ➡ 작업 수행
조건이 false이면 ❌ ➡ 아무 것도 하지 않음
점수가 90+이면 ➡ "Great job!" 출력
점수가 90 미만이면 ➡ 출력하지 않음
if (condition) {
// Code to run
}
조건이 true이면 중괄호 내부 코드가 실행됩니다.
==, !=, >, <, >=, <= 등의 비교 연산자를 사용합니다. // 점수가 >= 90이면 "Great job!" 출력
if (score >= 90) {
System.out.println("Great job!");
}
int score = 94;
if (score >= 90) {
System.out.println("Excellent!");
}
if (score >= 70) {
System.out.println("Good job!");
}
if (score < 70) {
System.out.println("Try again!");
}
Excellent!
Good job!
조건은 서로 다를 수 있으며 true/false로 평가됩니다.
if (score != 0){
System.out.println("Well, you got some points!");
}
if (message.equals("F")){
System.out.println("Try again!");
}
if (testResult == 100) {
System.out.println("Wow, you got it all!");
}
중급 Java