From the course: Learning Java 11
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Operators in Java
- [Instructor] Thinking back to the decision block in our control flow, we have three main components. We have a condition, the code that gets run if the condition is true, and the code that gets run if the condition is false. To simplify our condition, we can just write out our condition with the less than sign instead of writing it out in English. This is closer to what it will look like in our code. Ultimately, the value of inputting them or the number that the user inputs will determine which print statement is run, which is exactly what we want. We call the less than sign a relational operator. Its inputs are inputtedNum and five. And the relational operator, less than, states a comparison between these two inputs. The result of this overall comparison will evaluate to either true or false. Since the inputtedNum less than five comparison evaluates to a Boolean, we call it a Boolean expression. And a Boolean expression can be used as a condition for our decision blocks. Of course,…
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)
Mapping out program control flow3m 57s
-
(Locked)
Operators in Java2m 26s
-
(Locked)
Decision-making with if in Java4m 8s
-
(Locked)
Understanding scope in Java1m 39s
-
(Locked)
While loops (conceptually)1m 53s
-
(Locked)
While loops in Java3m 19s
-
(Locked)
Challenge: Multiple choice2m 22s
-
(Locked)
Sample solution: Multiple choice5m 1s
-
(Locked)
-
-
-
-