Read Java Interview Questions and Answers for Beginners and Experienced

Java Less than equal to operator example

In this post, we will study about Java Less than equal to Operator Example. How Less than equal to operator works with example.

 


Java Less than equal to Operator

Less than equal to is one of the Java comparison operators. It is used to evaluate and check the Less value between two variables. it is almost equal to Java Less than operator.

 


Syntax of Java Less than equal to operator

Below is the syntax of Java Less than equal to Operator.

X <= Y
  • Here X and Y are two variables.
  • <= is the Less than equal to operator which evaluates whether X is Less than or equal to Y.

Less than equal to operator is almost works same as Less than operator in Java. Only difference is that Less than equals to operator compares the equal value also, it means it will return true, if  X is Less than and equals to Y.

 


Java Less than equal to Operator Example

Let’s understand Java Less than equal to operator with example.


public class JavaExamples {

public static void main(String[] args) {
//Java Less than equal to Operator Example in Java
int a=10;
int b=20;
int c=10;

System.out.println(a <= b);
System.out.println(b <= c);
System.out.println(c <= a);

}

}

Output


true
false
true

Explanation

In above Java Less than equal to Operator Example, There are three variable a, b, c. We apply <= operator on a, b and c.

 


Java Less than equal to operator is used when we have to check left hand side variable is Less than or equals to Right hand variable.