Relational Operators in Java

Notes:

Relational Operators in Java Programming Language:

Relational operators are also known as comparison operators. They are used find the relationship between two values or compare the relationship between two values; on comparison they yield the result either true or false.

- There are 6 relational or comparison operators in Java. They are

< : less than
> : greater than

<= : less than or equal to
>= : greater than or equal to

== : equal to
!= : not equal to

Note:
- OR says if both LHS & RHS operands are false then the result will be false; otherwise the result will be true
LHS RHS LHS OR RHS
true true true
true false true
false true true
false false false

Example Code:
package relationaloperatorsdemo;

public class RelationalOperatorsDemo
{
public static void main(String[] args)
{
System.out.println(3 < 4); // true
System.out.println(5 < 4); // false

System.out.println(5 > 4); // true
System.out.println(5 > 6); // false

System.out.println(5 <= 6); // true
System.out.println(6 <= 6); // true
System.out.println(7 <= 6); // false

System.out.println(7 >= 6); // true
System.out.println(7 >= 7); // true
System.out.println(7 >= 8); // false

System.out.println(7 != 8); // true
System.out.println(7 == 8); // false

}
}