java and and or operators 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: Operators in java

// java unary (~) operator
public class JavaUnaryOperator
{
   public static void main(String[] args)
   {
      int a = 8, b = -4;
      System.out.println("a = " + a);
      System.out.println("b = " + b);
      System.out.println(a + " java bitwise complement is = " + ~a);
      System.out.println(b + " java bitwise complement ia = " + ~b);
   }
}

Tags:

Java Example