Print Logical NOT Result
This program prints the result of a logical NOT operation.
Problem Statement
Write a Java program that evaluates a logical NOT expression and prints the result.
Source Code
| 1 | public class LogicalNot { |
| 2 | public static void main(String[] args) { |
| 3 | boolean flag = false; |
| 4 | boolean result = !flag; |
| 5 | System.out.println("Result of NOT: " + result + " - Eduinq"); |
| 6 | } |
| 7 | } |
Program Output
Result of NOT: true - Eduinq
Explanation
A boolean variable flag is declared with the value false, and the logical NOT (!) operator inverts it to true, which is stored in result and printed, demonstrating how NOT inverts a boolean value.