Boolean Operation in Java
Simple Program that explains the Boolean Operations in Java.
Introduction
- In this blog, I am going to explain the program for Boolean Operations in Java.
Software Requirements
Program
- import java.io.*;
-
- public class booleanOperation{
- public static void main(String[] args) throws Exception{
- try{
- int a;
- int b;
- String str;
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- a = Integer.parseInt(in.readLine());
- b = Integer.parseInt(in.readLine());
- str = in.readLine();
- String as = new String(str);
- System.out.println("a = " + a + "and\nb = " + b);
- System.out.println(a + " is greater than " + b + " : " + (a > b));
- System.out.println(a + " is less than " + b + " : " + (a < b));
- System.out.println(a + " is equal to " + b + " : " + (a == b));
- System.out.println(a + " is greater or equal to " + b + " : " + (a >= b));
- System.out.println(a + " is less than or equal to " + b + " : " + (a <= b));
- System.out.println(a + " is not equal to " + b + " : " + (a != b));
- System.out.println(a + " is equal to " + b + " : " + (a == b));
- System.out.println("This condition is : " + (as.equals("Yes")));
- }
- catch(IOException e){
- System.out.println(e.getMessage());
- System.exit(0);
- }
- }
- }