Wednesday, December 31, 2008

What are Boolean Data types in Java

Welcome back to Java Code Online. Boolean Data Type is one of the most useful data type, when you need some sort of definitive action. Like it has to be a yes or no, nothing in between. It is exactly like binary, where the numbers could be 0 or 1, nothing else. Boolean Data type is one of the four groups of data types in Java which are Integer Data Type in Java, Floating Point Data Type, Character Data Types and the fourth is Boolean Data type itself.

The Boolean data type tests a particular condition or expression, and evaluates that the condition is "true" "false". The true and false are in quotes because these are the values which are returned while using a Boolean Data Type in Java.

In the Boolean Data type Category, there is only a single data type called:-
1. boolean (true or false)

The boolean data type tests a logical condition, and returns either true or false. The number of bits that a boolean variable occupies is JVM specific. Only two values are possible that are "true" or "false". The boolean data type is used extensively by the relational operators as the return type is always boolean, and also in loops. I will cover loops in Java later. For example:-

boolean b;

Then it is implicit that this variable "b" can have only two possible values and they are "true" or "false". Boolean data type are very handy while testing conditions.

I hope the article helped you get a groove on the Boolean Data types in Java. If you like this article then do post a comment. For more info on Java, keep buzzing Java Code Online.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.