Last Updated: 28 May, 2022
Operators are special symbols that perform the specified operations. Each operator is responsible to perform some specific operation on variables or values and return a result. The operators are classified and listed according to precedence order.
Java supports the following types of operators:
Relational Operators are a bunch of binary operators that are used to check for relations between two operands. Relational Operators return either true or false as a result after the comparison. Relational Operations are extensively used in looping statements as well as conditional if-else statements and so on.
Just for understanding the below table we assume X=10, Y=20
Operators | Description | Example | Output |
---|---|---|---|
== | Equal operator | X == Y | false |
!= | Not Equal operator | X != Y | true |
> | Greater than operator | X > Y | false |
< | Less than operator | X < Y | true |
>= | Greater than or equal to operator | X >= Y | false |
<= | Less than or equal to operator | X <= Y | true |
Example 1: A sample Java Program of Relational Operators
Output
false
true
false
true
false
true
Example 2: Perform Relational Operations Using Scanner Class
Output
Enter the marks and get the result:
55
Second Division
That's all guys, hope this Java article is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com