본문 바로가기
(Pre-class)

Nested if statement?

by coramdeo643 2025. 3. 31.

1. If statement in the if statement

// can be multi-if statements for more specific conditions and results

int temp = 20;
boolean isRain = true;

if (temp < 10) {
    if (isRain) {
    	System.out.println("Cold and rainy! Be careful!");
    } else {
    	System.out.println("It's cold outside!";
    } 
} else {
    System.out.println("It's such a good day, mate!");
} // end of if

'(Pre-class)' 카테고리의 다른 글

While loop?  (0) 2025.04.02
For Loop?  (0) 2025.04.01
If and If else?  (0) 2025.03.31
import java.util.Scanner?  (0) 2025.03.30
Logical operator?  (0) 2025.03.30