Java OR Operator Examples


The following simple example program demonstrates the logical OR operator. Copy and paste the following Java program into Test.java file and compile and run this program −

Example

Online Demo

public class Test {
   public static void main(String args[]) {
      boolean a = true;
      boolean b = false;
      System.out.println("a || b = " + (a || b) );
   }
}

Output

This will produce the following result −

a || b = true

Updated on: 15-Jun-2020

167 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements