본문 바로가기

[TIL]동등 연산자(==, !=) & 관계 연산자(<, <=, >, >=)

인포꿀팁 발행일 : 2020-07-22

오늘 배운내용은 동등 연산자 Equality operators와 관계 연산자 Relational operators 입니다.

 

1) 동등 연산자

먼저 동등 연산자는 오퍼랜드가 2개인 이항 연산자로 수식을 오퍼랜드로 취하여 결과값이 true /false 로 반환된다.

2) 관계 연산자

동등 연산자와 동일한 기능을 가지며 연산자에 따라 의미가 조금씩 다르다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package ex0722;
 
public class OperatorEx15 {
 
    public static void main(String[] args) {
        int a = 10;
        boolean b;
        System.out.println(a==10);// true
        System.out.println(a==20);// false
        
        System.out.println(a!=10);// false
        System.out.println(a!=20);// true
        
        b = a >10// false
        System.out.println(b);
        
        b = a >=10// true
        System.out.println(b);
    }
 
}
 
cs

 

 

'Language > JAVA' 카테고리의 다른 글

[TIL]조건연산자(삼항연산자)  (0) 2020.07.22
[TIL]논리 연산자(&&, ||)  (0) 2020.07.22
[TIL]증감연산자  (0) 2020.07.22
[TIL]이항 연산자  (0) 2020.07.22
[TIL] print() 과 println() 메소드  (0) 2020.07.22

댓글