Introduction

  • In this blog, I am going to explain the program for Boolean Operations in Java.
Software Requirements
  • Java, Notepad
Program
  1. import java.io.*;
  2. public class booleanOperation {
  3. public static void main(String[] args) throws Exception {
  4. try {
  5. int a;
  6. int b;
  7. String str;
  8. BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  9. a = Integer.parseInt( in .readLine());
  10. b = Integer.parseInt( in .readLine());
  11. str = in .readLine();
  12. String as = new String(str);
  13. System.out.println("a = " + a + "and\nb = " + b);
  14. System.out.println(a + " is greater than " + b + " : " + (a > b));
  15. System.out.println(a + " is less than " + b + " : " + (a < b));
  16. System.out.println(a + " is equal to " + b + " : " + (a == b));
  17. System.out.println(a + " is greater or equal to " + b + " : " + (a >= b));
  18. System.out.println(a + " is less than or equal to " + b + " : " + (a <= b));
  19. System.out.println(a + " is not equal to " + b + " : " + (a != b));
  20. System.out.println(a + " is equal to " + b + " : " + (a == b));
  21. System.out.println("This condition is : " + (as.equals("Yes")));
  22. } catch (IOException e) {
  23. System.out.println(e.getMessage());
  24. System.exit(0);
  25. }
  26. }
  27. }