Jumat, 05 April 2013

Contoh Program Java Operator Logika


class DemoOperatorLogika {
  public static void main(String[] args) {


    System.out.println("Operasi AND");
    System.out.println("true && true   = " + (true && true));
    System.out.println("true && false  = " + (true && false));
    System.out.println("false && true  = " + (false && true));
    System.out.println("false && false = " + (false && false));

    System.out.println("\nOperasi OR");
    System.out.println("true || true   = " + (true || true));
    System.out.println("true || false  = " + (true || false));
    System.out.println("false || true  = " + (false || true));
    System.out.println("false || false = " + (false || false));

    System.out.println("\nOperasi XOR");
    System.out.println("true ^ true    = " + (true ^ true));
    System.out.println("true ^ false   = " + (true ^ false));
    System.out.println("false ^ true   = " + (false ^ true));
    System.out.println("false ^ false  = " + (false ^ false));

    System.out.println("\nOperasi NOT");
    System.out.println("!true          = " + (!true));
    System.out.println("!false         = " + (!false));
  }
}

1 komentar: