Enter two integer numbers as input. After that we match both the inputs with the help of equal to(==) operator. Hence we generate the output accordingly.
Here is the source code of the Java Program to Accept two Integers and Check if they are Equal. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
public class Equal_Integer
public static void main(String args)
int m, n;
Scanner s = new Scanner(System.in);
System.out.print("Enter the first number:");
m = s.nextInt();
System.out.print("Enter the second number:");
n = s.nextInt();
if(m == n)
System.out.println(m+" and "+n+" are equal ");
System.out.println(m+" and "+n+" are not equal ");
$ javac Equal_Integer.java $ java Equal_Integer Enter the first number:5 Enter the second number:7 5 and 7 are not equal Enter the first number:6 Enter the second number:6 6 and 6 are equal
Sanfoundry Global Education & Learning Series – 1000 Java Programs.