From the course: Java 11+ Essential Training
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Manage true and false Boolean values - Java Tutorial
From the course: Java 11+ Essential Training
Manage true and false Boolean values
- [Instructor] A variable with a primitive data type of Boolean can have a value of either true or false. In some languages, the values true or false can also be represented as numeric values, but in Java, that's not the case. The key words true and false are the only possible Boolean values. To create a Boolean variable explicitly, start with the type name Boolean, then set the variable name or identifier, and assign either true or false. You can also use inferred typing. I'll create a variable starting with var. I'll call this one B1 and I'll set it to true. And I'll create another one called B2 and set it to false. So those are also variables with a primitive data of Boolean. If you declare a Boolean value without setting its initial value, it'll default to false. So if I create Boolean B3, I see that it's false. You can reverse a Boolean value, set it from true to false or false to true using the negation operator,…
Contents
-
-
-
-
-
(Locked)
Work with primitive variables5m 43s
-
(Locked)
Declare and modify primitive values3m 27s
-
(Locked)
Declare and initialize object variables3m 40s
-
(Locked)
Manage currency values with BigDecimal3m 8s
-
(Locked)
Convert values between numeric types2m 40s
-
(Locked)
Math operators and the Math class2m 22s
-
(Locked)
Manage true and false Boolean values2m 43s
-
Manage character values as primitives3m 13s
-
(Locked)
More about Java operators5m 45s
-
(Locked)
-
-
-
-
-
-
-