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

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.


HTML Image tag, code...
How to code in HTML...
HTML text tag...
HTML text, how to display...
Container responsive styles...
HTML container tag...
HTML container...
Send forgot password by mail or message ...
PHP MySQL simple login system...
Check for duplicate username live or ema...
How to create simple search engine using...
Diseño de sitio web CSS Layout...
Diseño de caja flexible CSS3...
Botones en CSS...
ID y Clase, Diferencias entre Class e Id...
Esquina redondeada CSS...
Tamaño de caja css box-sizing: border-b...
Alineación CSS...
Altura y Anchura CSS...
Bordes CSS...