AND OR operator java code example
Example 1: java or
int num = 9;
if (num == 1 || num == 2) {
System.out.println("Nope");
}
if (num == 1 || num == 9) {
System.out.println("Yep");
}
Example 2: |= java operator
foo = 32;
bar = 9;
baz = 10;
foo |= bar;
foo |= baz;
Example 3: Operators in java
public class JavaUnaryOperator
{
public static void main(String[] args)
{
boolean bool = true;
int a = 14, b = 5;
System.out.println("Before using java unary ! operator: " + bool);
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("After using java unary ! operator: " + !bool);
System.out.println("!(a < b) = " + !(a < b));
System.out.println("!(a > b) = " + !(a > b));
}
}