AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

Java Boolean


Java Tutorial » Java Boolean

In Java, the boolean keyword it is used to store only two possible values, as:

TRUE / FALSE or
YES / NO
Its default value is "false".

Boolean data type in Java, can take one of this value: true or false.


Boolean Values, example


Type boolean is used with the boolean keyword and it can have only one of this values: true or false:

Example:
public class Main {
public static void main(String[] args) {

boolean i_like_java = true;
boolean is_warm_in_winter = false;

System.out.println("I like Java: " + i_like_java);
System.out.println("It is warm in winter: " + is_warm_in_winter);
}
}
Output:
I like Java: true
It is warm in winter: false


Boolean Expression


In Java Boolean expression is an expression that returns Boolean value like: true or false.

For next esample we use an operator, as "the greater than" (>) operator to find out if an variable or expresion is true or false:

Example: use the + method
public class Main {
public static void main(String[] args) {
int x = 20;
int y = 18;
boolean a1 = true;
boolean a2 = false;

if (x < y) {
System.out.println(a1);
}
else
{
System.out.println(a2);
}
}
}
Output:
false




Java Boolean default value, to string, operators, class, to int, vs boolean, null, ejemplo, array, type, true false, method
Java Boolean - java

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


0
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


jQuery replace...
jQuery replaceClass...
jQuery click ()...
jQuery switchClass()...
jQuery draggable()...
jQuery HTML...
jQuery scroll smooth...
jQuery scroll()...
jQuery stop()...
jQuery animate()...
jQuery SlideToggle()...
jQuery slideDown()...
jQuery slideUp()...
jQuery fadeToggle...
jQuery fadeOut()...
jQuery fadeIn()...
jQuery Effects - hide () and show ()...
jQuery Events...
jQuery Attributes...
jQuery Selectors...