Print Equality Check
This program prints the result of an equality check.
Problem Statement
Write a Java program that checks if two numbers are equal and prints the result.
Source Code
| 1 | public class EqualityCheck { |
| 2 | public static void main(String[] args) { |
| 3 | int a = 10, b = 20; |
| 4 | boolean result = (a == b); |
| 5 | System.out.println("Are a and b equal? " + result + " - Eduinq"); |
| 6 | } |
| 7 | } |
Program Output
Are a and b equal? false - Eduinq
Explanation
Two integers a and b are declared, and the expression (a == b) checks whether they are equal, storing the result in a boolean variable that is then printed, showing how the equality operator works with integers.