디케이
비교연산자 본문
반응형
== , != , < , > , <= , >=
- 비교 연산자의 결과는 boolean이다.
int i = 10; // = 대입연산자
int j = 10; // i 와 j 가 같은지 비교 하는 비교 연산자
System.out.println(i == j ); // i 와 j가 같은지 비교 출력
System.out.println(i != j ); // i 와 j가 다른지 비교 출력
System.out.println(i < j); // i가 j 보다 작은지 비교 출력
System.out.println( i <= j); // i가 j보다 작거나 같은지 비교 출력
System.out.println(i > j); // i가 j 보다 큰지 비교 출력
System.out.println(i >= j); // i가 j보다 크거나 같은지 비교 출력
-
단순 대입 연산자
- i = 10
- 오른쪽에 있는 피연산자의 값을 왼쪽 피연산자의 변수에 저장
-
복합 대입 연산자
- 정해진 연산을 수행한 후에 결과를 대입
i += 10; // i = i + 10; 과 같은 의미
System.out.println(i);
System.out.println(i -=5);
System.out.println(i);
반응형