Sample Code
public class Boolean_Example{
public static void main(String[] args) {
boolean b= true ;
System.out.println("JAVA is Object Oriented Programming language :- " + b );
System.out.println("JAVA is platform independent :- " + b );
boolean b1= false ;
System.out.println("JAVA is platform dependent :- " + b );
}
}
Example Code with Condition
public class BooleanWithCondition {
public static void main(String[] args) {
// boolean variable is to present either true(1) or false(0)
boolean result = true;
if (result) {
// this will be executed if result =true
System.out.println("The result is" + result);
} else {
// this will be executed if result =false
System.out.println("The result is " + result);
}
result = false;
if (result) {
// this will be executed if result =true
System.out.println("The result is " + result);
} else {
//this will be executed if result =false
System.out.println("The result is " + result);
}
}
}