Web | This Site

Java Basics
Java Object Oriented
Java Advanced
Java Useful References
Java Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# Java Logical Operators Example

The following simple example program demonstrates the logical operators. Copy and paste following Java program in Test.java file and compile and run this program. :

    class Test {
    public static void main(String args[]) {
       int a = true;
       int b = false;

       System.out.println("a && b = " + (a&&b) );

       System.out.println("a || b = " + (a||b) );

       System.out.println("!(a && b) = " + !(a && b) );
    }
    }

This would produce following result:

    a && b = false
    a || b = true
    !(a && b) = true

Advertisement

Online Image Processing

Indian Baby Names