Relational operators are used to compare the relationship between two values. The operation result is of boolean type . When the relationship corresponding to the operator is established, the operation result is true and false .
Suppose the value of variable a is 10 and the value of variable b is 5:
Example:
publicclassMain{publicstaticvoidmain(String[]args){inta=5;intb=10;System.out.println(a==b=+(a==b));System.out.println(a!=b=+ (a!=b));System.out.println(a>b=+(a>b));System.out.println(a<b=+(a<b));System.out.println( a>=b=+(a>=b));System.out.println(a<=b=+(a<=b));}}
The running results are as follows:
a==b=falsea!=b=truea>b=falsea<b=truea>=b=falsea<=b=true