In this java article, we will be covering OR logical operator in Java. OR logical operator means one of conditions need to evaluate TRUE.
Lets look to syntax of it in Java.
int x = 1;
int y= 5;
if(x > y | x == 1) //??? ??????
{
System.out.println("x > y OR x = 1");
}
else
{
System.out.println("else..");
}
Lets see it in Java code example.
In above example, we declared two variable and used "|" operator as OR operation. If block executes if one condition is TRUE. To test it, we printed both condition IF and ELSE. In our example, x was 1 and it caused or OR condition to evaluate TRUE.