Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

Java Relational Operators

Relational operators are binary operators. Java supports six relational operators like, <, >, <=, >=, ==, & != .
It is also known as Comparison operator.
It returns a boolean value(true / false).

These operators are used when some comparisons will arise between two operands. For example, Let the value of a and b is 15 and 20 respectively.

If write a<b, then it is a case of comparison. This relational expression is evaluated as either true or false. So the value this expression is true. Let's see a program to understand these operators.

Example
Class RelationalDemo
{
	public static void main(String args[])
	{
		int x=10,y=15,z=20;
		boolean p;
		boolean q;
		p=x<y;
		q=y>z;

		System.out.println(x);
		System.out.println(y);
		System.out.println(z);
		System.out.println(p);
		System.out.println(q);
	}
}

Output:

10
15
20
true
false

About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext