Chapter Table of Contents
Section Table of Contents
So a while back, we talked about booleans. Now we will combine that skill with conditionals to really gain control and manipulate our Java programs.
Recall that booleans can only have 2 states:
false. This is very handy when we need to pick and choose which code to run. For instance, what if I wanted to make a program that printed out whether I could vote depending on what my age is?
I could have a
canVote, which stores whether I can vote or not. To be more specific, I could have a condition like:
age is greater than or equal to 18. How do we represent expressions with inequalities? We can use relational operators.