From the course: Java 8 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Working with Boolean values and expressions - Java Tutorial
From the course: Java 8 Essential Training
Working with Boolean values and expressions
- A variable marked with the boolean data type can have a value of either true or false. I'll demonstrate this in the booleans project. Within the main method, I'll declare two variables, and I'll start with the keyword boolean, all lower case. That means this is a primitive variable, not an object. I'll name the variable b1, and I'll assign it a value of true. Then, I'll create another boolean variable, and I'll say that one is false. Now, I'm going to shrink down my project window to eliminate some flickering that's happening, then I'll add some output to the console. I'll start with a string of "The value of b1 is" and then I'll append the value b1. I'll duplicate that line of code, and change both the label and the value, and then I'll run the class. And I get the expected output. The values of the primitive variables, b1 and b2, have been translated to equivalent strengths. So, true gets a string of true, and false gets a string of false. All primitive variables, as I've…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Working with primitive variables8m 4s
-
(Locked)
Declaring and initializing numeric primitives6m 14s
-
(Locked)
Representing currency values with BigDecimal5m 10s
-
(Locked)
Converting numeric values5m 37s
-
(Locked)
Using mathematical operators and the Math class6m 1s
-
(Locked)
Working with Boolean values and expressions4m 49s
-
(Locked)
Working with character values3m 23s
-
(Locked)
Using Java operators6m 11s
-
(Locked)
-
-
-
-
-
-
-
-
-