inblog logo
|
sxias
    자바

    [JAVA] 8. 관계연산자

    문정준's avatar
    문정준
    Feb 05, 2025
    [JAVA] 8. 관계연산자
    Contents
    코드 작성결과

    코드 작성

    package ex02; public class CompOperator { public static void main(String[] args) { // 1. x == y : x와 y가 같으면 True System.out.print((3 == 4) + " "); // 2. x != y : x와 y가 다르면 True System.out.print((3 != 4) + " "); // 3. x > y : x가 y보다 크면 True System.out.print((3 > 4) + " "); System.out.print((4 > 3) + " "); // 4. A && B : A, B가 모두 참이면 True System.out.print((3 == 3 && 4 == 7) + " "); // 5. A || B : A, B중 하나라도 참이면 True System.out.print((3 == 3 || 4 == 7) + " "); } }
    • 연산자에 따른 참, 거짓 결과 확인
      • x == y : x, y가 같으면 참, 아니면 거짓
      • x ≠ y : x, y가 다르면 참, 아니면 거짓
      • x > y : x가 y보다 크면 참, 아니면 거짓
      • x && y : x, y가 전부 참이면 참, 아니면 거짓
      • x || y : x, y 중 하나라도 참이면 참, 아니면 거짓

    결과

    notion image
     
    💡
    문제 요점
    1. 연산자에 따른 참, 거짓 여부에 유의
     
    Share article
    Contents
    코드 작성결과

    Sxias ㆍ a32176740@gmail.com

    RSS·Powered by Inblog