Showing posts with label Boolean. Show all posts
Showing posts with label Boolean. Show all posts

Friday, February 8, 2013

Week-3 : 3.3: Boolean Statement

Boolean:

A Boolean value is one with two choices: true or false, yes or no, 1 or 0. In Java, there is
a variable type for Boolean values:

boolean user = true;

So instead of typing int or double or string, you just type boolean (with a lower case "b").
After the name of you variable, you can assign a value of either true or false. Notice
that the assignment operator is a single equals sign ( = ). If you want to check if a
variable "has a value of" something, you need two equal signs ( = =).

Try this simple code:

boolean user = true;

if ( user == true) {
System.out.println("it's true");
}
else {
System.out.println("it's false");
}

Visit for Details