javacodex.com
Java Examples
Java Examples
memu home questions

Equality Operators

This java program example demonstrates the use of equality operators.

Source: (EqualityOperators.java)

public class EqualityOperators {
   public static void main(String[] args) {
 
      boolean a = 10 == 1;
      boolean b = 10 == 10;
      boolean c = 10 != 1;
      boolean d = 10 != 10;
      boolean e = 5.0 == 5L ;
      boolean f = true != false ;
 
      System.out.println("a = " + a );
      System.out.println("b = " + b );
      System.out.println("c = " + c );
      System.out.println("d = " + d );
      System.out.println("e = " + e );
      System.out.println("f = " + e );
   }
}
 

Output:

# java EqualityOperators 
a = false
b = true
c = true
d = false
e = true
f = true

Contact: javacodex@yahoo.com