0% found this document useful (0 votes)
15 views2 pages

Relational Operators

Java Relational Operators are binary operators used to evaluate relationships between two operands, returning boolean results. They include equality (==), inequality (!=), greater than (>), less than (<), greater than or equal to (>=), and less than or equal to (<=). These operators are commonly used in conditional statements and loops.

Uploaded by

nikhil602104
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Relational Operators

Java Relational Operators are binary operators used to evaluate relationships between two operands, returning boolean results. They include equality (==), inequality (!=), greater than (>), less than (<), greater than or equal to (>=), and less than or equal to (<=). These operators are commonly used in conditional statements and loops.

Uploaded by

nikhil602104
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

05-Relational Operators

Java Relational Operators are binary operators that are used to evaluate
relationships between two operands, such as equality, greater than, less than,
and so on. These comparisons return boolean results, and they are commonly
used in looping statements, conditional if-else statements, and similar
constructs. The standard format for representing a relational operator is:

Syntax:
variable1 relational_operator variable2

implementation:
Equality (==): Checks if two values are equal.
Inequality (!=): Checks if two values are not equal.
Greater than (>): checks if the left operand is greater than the right operand.

Less than (<): Checks if the left operand is less than the right operand.
Greater than or equal to (>=): Checks if the left operand is greater than or
equal to the right operand.
Less than or equal to (<=): Checks if the left operand is less than or equal to the
right operand.

Examples of Each Operator:

int a = 10;
int b = 20;

// Equality (==)
System.out.println(a == b); // Output: false
// Inequality (!=)
System.out.println(a != b); // Output: true

// Greater than (>)


System.out.println(a > b); // Output: false

// Less than (<)


System.out.println(a < b); // Output: true

// Greater than or equal to (>=)


System.out.println(a >= b); // Output: false

// Less than or equal to (<=)


System.out.println(a <= b); // Output: true

You might also like