Java - Less Than or Equal to Operator <=

What is Less Than or Equal to Operator?

The less than or equal to operator (<=) is used in the form

operand1 <= operand2 
  

The less than or equal to operator returns true if the value of operand1 is less than or equal to the value of operand2. Otherwise, it returns false.

The operator can be used only with primitive numeric data types.

If either of the operand is NaN (float or double), the less than or equal to operator returns false.

Example

The following code shows how to use Less Than or Equal to Operator.

int i = 10; 
int j = 10; 
int k = 15; 
boolean b; 
  
b = (i <= j);  // Assigns true to b 
b = (j <= i);  // Assigns true to b 
b = (j <= k);  // Assigns true to b 
b = (k <= j);  // Assigns false to b 

Demo

public class Main {
  public static void main(String[] args) {
    int i = 10; /* w ww  . j a va 2  s . c  om*/
    int j = 10; 
    int k = 15; 
    boolean b; 
      
    b = (i <= j);  // Assigns true to b
    System.out.println(b);
    b = (j <= i);  // Assigns true to b
    System.out.println(b);
    b = (j <= k);  // Assigns true to b
    System.out.println(b);
    b = (k <= j);  // Assigns false to b 
    System.out.println(b);
  }
}

Result