Relational and logical operators : Relational Operators « Operators « Java Tutorial






import java.util.Random;

public class MainClass {
  public static void main(String[] args) {
    Random rand = new Random();
    int i = rand.nextInt(100);
    int j = rand.nextInt(100);
    System.out.println("i = " + i);
    System.out.println("j = " + j);
    System.out.println("i > j is " + (i > j));
    System.out.println("i < j is " + (i < j));
    System.out.println("i >= j is " + (i >= j));
    System.out.println("i <= j is " + (i <= j));
    System.out.println("i == j is " + (i == j));
    System.out.println("i != j is " + (i != j));

    System.out.println("(i < 10) && (j < 10) is " + ((i < 10) && (j < 10)));
    System.out.println("(i < 10) || (j < 10) is " + ((i < 10) || (j < 10)));
  }
}
i = 92
j = 22
i > j is true
i < j is false
i >= j is true
i <= j is false
i == j is false
i != j is true
(i < 10) && (j < 10) is false
(i < 10) || (j < 10) is false








3.6.Relational Operators
3.6.1.Relational Operators
3.6.2.Relational and logical operators