Relational Operators in Java

Relational Operators in Java:

We can use the Eclipse IDE for this example. If you do not know about it then follow this link- How to Install Eclipse For Java and create a program in it.

Computers can make simple decisions. For example, a computer program can take one path of action if two variables, x and y, are equal, another path if x is greater than y, and yet another one if y is greater than x. The Java relational operators evaluate if a simple relationship between operands is true or false.

OperatorActionExampleResult
<less than4 < 1false
>greater than4 > 1true
<=less than or equal to4 <= 1false
>=greater than or equal to4 >= 1true
==equal to4 == 1false
!=not equal to4 != 1true
Java Relational Operators
package com.java_tutorial;

public class Relational_operators {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		int x = 4;
		int y = 1;
		
	    boolean z = x < y;
	    System.out.println("x < y Result: "+ z);
	    
	    boolean za = x > y;
	    System.out.println("x > y Result: "+ za);
	    
	    boolean zb = x <= y;
	    System.out.println("x <= y Result: "+ zb);
	    
	    boolean zc = x >= y;
	    System.out.println("x >= y Result: "+ zc);
	    
	    boolean zd = x == y;
	    System.out.println("x == y Result: "+ zd);
	    
	    boolean ze = x != y;
	    System.out.println("x != y Result: "+ ze);
	    
	    }
}

Modules in Python
Math Modules in Python
Python Random Module
Python Datetime Module
Python Bike Rental System
Java (programming language)– Wikipedia

Comments (No)

Leave a Reply