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) );
}
}