Keyword in Java

The boolean keyword in Java programming language

The boolean keyword in java programming language

In this tutorial , We will learn about the boolean keyword in java programming language

In Java language, Boolean is used to declare a variable as a boolean type. This represents only either true or false(Zero or one).

In Java language, default boolean value  is initialized with false;

Declare a boolean variable

Syntax

syntax of float data type declaration

boolean <variable_name> = <boolean_value>;

Example

Example for float data type declaration

boolean  isSmallest=true;

The boolean keyword can be used to declare a return type of method in Java

 

Declare a boolean method

Syntax

<access_modifier> <return_type> <method_name>;
{
return <method_name>;
}

Example

public boolean Islargest()
{
return getBalance;
}

 

Example of boolean variable with in class

public class Example _boolean{  // this is a class in java
public static void main(String args[]){ // this is a main method in java
}
public boolean Iscorrect(){  // this is a boolean method which returns value;
}
}

Example

public class Boolean_Key{
    public static void main(String args[]){
     int age=20;
     boolean a=true, b=false;
        if(age>18){
          System.out.println(a);
                  }
        else{
           System.out.println(a);
            }
        }
    }

 

When the above code is compiled and executed, it will produce the following results

true

 

There are other Java language keywords that are similar to this keyword

 byte keyword in Java

 short keyword in Java

 int keyword in Java

long keyword in Java

 float keyword in Java

The char keyword in Java

 void keyword in Java

try keyword in Java

Catch keyword in Java

implements keyword in java

public Key words in Java

static keyword in Java language

Volatile Keyword in Java

Transient keyword in Java

Package keyword in Java

class keyword in Java

boolean keyword in Java

break keyword in Java

do keyword in Java

double keyword in Java

This keyword in Java

final keyword in Java

switch keyword in Java

interface keyword in java

extends keyword in Java language

 

Suggested for you

 Java language Keywords

C language Keywords

 Python language Keywords

keywords in C language

Usage of final keyword in Java

Usage of this keyword in Java

Finally keyword in Java language

 

s

 

The double keyword in Java programming language
The while keyword in Java programming language
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago