logical or operators in java code example

Example 1: Operators in java

// Arithmetic operators in java
public class ArithmeticOperatorDemo
{
   public static void main(String[] args)
   {
      int i = 25;
      int j = 5;
      System.out.println(i + j);
      System.out.println(i - j);
      System.out.println(i * j);
      System.out.println(i / j);
      System.out.println(i % j);
   }
}

Example 2: Operators in java

// example on java unary NOT (!) operator
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));
   }
}

Tags:

Java Example