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.
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
public class Main { public static void main(String[] args) { int i = 10; /*from w ww . j a v a2 s . co m*/ 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); } }