Comparison operator
Comparison operators are used to compare two values or variables, and the result is a boolean , that is, false or true.
Operator | Calculation | example | result |
== | equal to | 4==3 | false |
!= | not equal to | 4!=3 | true |
< | Less than | 4<3 | false |
> | more than the | 4>3 | true |
<= | Less than or equal to | 4<=3 | false |
>= | greater or equal to | 4>=3 | true |
Exercise:
public class TestOpe10{ public static void main(String[] args){ //比较运算符 System.out.println(4==3); //false System.out.println(4!=3); //true System.out.println(4<3); //false System.out.println(4>3); //true System.out.println(4<=3); //false System.out.println(4>=3); //true } }
operation result: