More operators
We can already add (+
), take away (-
), multiply (*
), divide (/
), assign (=
) increment (++
) and decrement (--
) with operators. Let's introduce some more super-useful operators, and then we will go straight on to understand how to use them in Java.
Tip
Don't worry about memorizing every operator below. Take a glance at them and their explanations and then move quickly on to the next section. We will put some operators to use soon and they will become much clearer as we see a few examples of what they allow us to do. They are presented here in a list just to make the variety and scope of operators plain from the start. The list will also be more convenient to refer back to when not intermingled with the discussion about implementation that follows it.
We use operators to create an expression which is either true or false. We wrap that expression in parentheses like this: (expression goes here)
.
- The comparison operator (
==
). This tests for equality and is either true...