Relational Operators In Java Example

Chapter: Operators Last Updated: 11-06-2016 19:42:08 UTC

Program:

            /* ............... START ............... */
                
public class JavaRelationalOperatorExample {

	public static void main(String args[]) {
		int a = 20;
		int b = 30;
		System.out.println("a == b = " + (a == b));
		System.out.println("a != b = " + (a != b));
		System.out.println("a > b = " + (a > b));
		System.out.println("a < b = " + (a < b));
		System.out.println("b >= a = " + (b >= a));
		System.out.println("b <= a = " + (b <= a));
	}
}
                /* ............... END ............... */
        

Output

a == b = false
a != b = true
a > b = false
a < b = true
b >= a = true
b <= a = false

Notes:

  • The equality and relational operators determine if one operand is greater than, less than, equal to, or not equal to another operand.
  • == Equal to
  • != Not equal to
  • > Greater than
  • >= Greater than or equal to
  • < Less than
  • <= Less than or equal to

Tags

Relational Operators, Java

Similar Programs Chapter Last Updated
Java Left Shift Operator Operators 04-09-2018
Java Addition Operator Operators 18-05-2017
Java Right Shift Operator Operators 13-12-2016
Prefix Operator In Java Example Operators 19-06-2016
Logical Operators In Java Example Operators 17-06-2016
Operator Precedence In Java Examples Operators 17-06-2016
Ternary Operators In Java Example Operators 15-07-2016
Modulus Operators In Java Example Operators 15-07-2016
Increment And Decrement In Java Example Operators 15-07-2016
Boolean Operator In Java Example Operators 15-07-2016
Bitwise Operator In Java Example Operators 16-06-2017
Assignment Operation In Java Example Operators 06-04-2016
Arithmetic Operation In Java Example Operators 11-06-2016

1