Java - Logical OR Operator |

What is Logical OR Operator?

The logical OR operator | is used in the form

operand1 | operand2 
  

The logical OR operator returns true if either operand is true. If both operands are false, it returns false.

The logical OR operator evaluates its right-hand operand even if its left-hand operand evaluates to true.

  
int i = 10; 
int j = 15; 
boolean b = (i > 5 | j > 10); // Assigns true to b 

Demo

public class Main {
  public static void main(String[] args) {
    int i = 10; /* www  .j a v a2s  .  c  om*/
    int j = 15; 
    boolean b = (i > 5 | j > 10); // Assigns true to b 
    System.out.println ("b = " + b); 

  }
}

Result

Exercise