how to declare and use Java primitive boolean variable - Java Language Basics

Java examples for Language Basics:boolean

Description

how to declare and use Java primitive boolean variable

Demo Code


 
public class Main {
 
        public static void main(String[] args) {
                boolean b1 = true;
                boolean b2 = false;
                boolean b3 = (5 > 2)? true:false;
               //from w w w  .j  a  va  2s  .  c  om
                System.out.println("Value of boolean variable b1 is :" + b1);
                System.out.println("Value of boolean variable b2 is :" + b2);
                System.out.println("Value of boolean variable b3 is :" + b3);            
        }
}

Result


Related Tutorials