Java program to perform the boolean operations
KW.java
class KW { public static void main(String args[]) { boolean a=true,b=false; System.out.println("———————————————————————————————————————————"); System.out.println("Program to perform the boolean operations"); System.out.println("———————————————————————————————————————————"); System.out.println(a+" | "+b+"\t| "+(a|b)); System.out.println(a+" & "+b+"\t| "+(a&b)); System.out.println(a+" ^ "+b+"\t| "+(a^b)); System.out.println(a+" || "+b+"\t| "+(a||b)); System.out.println(a+" && "+b+"\t| "+(a&&b)); System.out.println(a+" == "+b+"\t| "+(a==b)); System.out.println(a+" != "+b+"\t| "+(a!=b)); System.out.println("!("+a+" || "+b+")| "+!(a||b)); System.out.println("———————————————————————————————————————————"); } }
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW ——————————————————————————————————————————— Program to perform the boolean operations ——————————————————————————————————————————— true | false | true true & false | false true ^ false | true true || false | true true && false | false true == false | false true != false | true !(true || false)| false ——————————————————————————————————————————— kodingwindow@kw:~$
Comments and Reactions
What Next?
Java program to perform the relational operations
Java program to perform the assignment operations
Java program to find the size of primitive data types
Advertisement