package com.study.javastudy.study;

public class OperatorExam6 {
    public static void main(String[] args) {
        int b1 = (5 > 4) ? 50 : 40; // 5가 4크나요? 참이라면 50, 거짓이라면 40 b1에 저장
        int b2 = (5 < 4) ? 50 : 40; // 5가 4작나요? 참이라면 50, 거짓이라면 40 b1에 저장

        System.out.println(b1); // 50
        System.out.println(b2); // 40

        int b3 = 0;
        if(5 < 4) {
            b3 = 50;
        } else {
            b3 = 40;
        }
        System.out.println(b3); // 40

        int b4 = 0;
        if(5 > 4) {
            b4 = 50;
        } else {
            b4 = 40;
        }
        System.out.println(b4); // 50
    }
}

'자바 기초' 카테고리의 다른 글

while 반복문  (0) 2024.01.26
switch 조건문  (0) 2024.01.26
논리 연산자  (0) 2024.01.26
if 조건문  (0) 2024.01.26
연산자 우선순위  (1) 2024.01.26

+ Recent posts