반응형
Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

디케이

비교연산자 본문

카테고리 없음

비교연산자

디케이형 2020. 10. 17. 17:11
반응형

== , != , < , > , <= , >=

  • 비교 연산자의 결과는 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);
반응형