Copyright © tutorialspoint.com
The following simple example program demonstrates the logical operators. Copy and paste following Java program in Test.java file and compile and run this program. :
class Test { public static void main(String args[]) { int a = true; int b = false; System.out.println("a && b = " + (a&&b) ); System.out.println("a || b = " + (a||b) ); System.out.println("!(a && b) = " + !(a && b) ); } } |
This would produce following result:
a && b = false a || b = true !(a && b) = true |
Copyright © tutorialspoint.com