Menu
Topics Index
...
`


Datatypes > Primtive Dataypes > Literals >
Siva Nookala - 11 Apr 2016
The values true and false are treated as boolean literals in Java.

In Boolean Literals, When we assign a value to a boolean variable, we can only use either true or false. Unlike C, we can't presume that the value of 1 is equivalent to true and 0 is equivalent to false in Java. Boolean literals are used to initialize primitive data type boolean. e.g.,
boolean chosen = true;
boolean result = false;

//Invalid
boolean test_value = 1;
boolean test_value2 = 2288;
boolean test_value3 = 0;

0
Wrong
Score more than 2 points

© meritcampus 2016 - 2017

All Rights Reserved.