<= in java: In the previous article, we have discussed about Java Program on Greater Than or Equal To Operator
In this article we will see the use of Less Than or Equal To operator in Java programming language.
Java Program on Less Than or Equal To Operator
Less Than or Equal To Operator:
Less Than or Equal To operator is a relational operator which is used for comparison purpose. It checks if the value of left hand operator is less than or equal to the value of right hand operator.
Syntax: operand1 <= operand2
Let’s see an program to understand the use of operator more clearly.
import java.util.Scanner; class Main { public static void main(String[] args) { //Scanner class object created Scanner in=new Scanner(System.in); //Taking input of 2 numbers System.out.println("Enter any two numbers: "); int n1=in.nextInt(); int n2=in.nextInt(); //checking if first value is less than or equal to second value if(n1<=n2) { System.out.println(n1+" is less than or equal to "+ n2+ " : True"); } else { System.out.println(n1+" is less than or equal to "+ n2+ " : False"); } } }
Output: Case-1 Enter any two numbers: 563 564 563 is less than or equal to 564 : True Case-2 Enter any two numbers: 564 777 564 is greater than or equal to 777 : True Case-3 Enter any two numbers: 564 299 564 is less than or equal to 299 : False
Are you wondering how to seek help from subject matter experts and learn the Java language? Go with these Basic Java Programming Examples and try to code all of them on your own then check with the exact code provided by expert programmers.
Related Java Programs: