Java simple type boolean
is for logical values.
boolean
variable can have only one of two possible values, true
or false
.
boolean
is the type returned by all relational operators and conditional expressions that control statements such as if
and for
.
When a boolean
value is output by println(), "true" or "false" is displayed.
The following code defines a boolean
type variable and assign false
value to it.
public class Main {
public static void main(String args[]) {
boolean b;
b = false;
System.out.println("b is " + b);
}
}
The output generated by this program is shown here:
b is false
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |