boolean keyword in Java

The boolean keyword is used to declare a variable as a boolean type, which represents only either true or false.

For example:

  1. boolean isActive;
  3. boolean isAdmin;
boolean isActive;

boolean isAdmin;

The boolean keyword can be used to declare a type of a method parameter as below:

  1. public void sendEmail(boolean isAdmin) {
  3.  if(isAdmin){
  5.                        //Send email only for Admin
  6.             }
  8. }
public void sendEmail(boolean isAdmin) {

                       //Send email only for Admin


The boolean keyword can also be used to declare return type of a method as below:

  1. public boolean isSeniorCitizen() {
  3. if(age >=60){    
  4.                  return true;
  5.             }
  6. else{
  7.          return false;
  8.     }
  9. }
public boolean isSeniorCitizen() {

if(age >=60){    
                 return true;
         return false;

About the Author

Karibasappa G C (KB)
Founder of
I love Java and open source technologies and very much passionate about software development.
I like to share my knowledge with others especially on technology 🙂
I have given all the examples as simple as possible to understand for the beginners.
All the code posted on my blog is developed,compiled and tested in my development environment.
If you find any mistakes or bugs, Please drop an email to

Connect with me on Facebook for more updates

Share this article on