previous |
start |
next
Equality Testing vs. Assignment
- The == operator tests for equality:
if (x == 0) . . // if x equals zero
- The = operator assigns a value to a variable:
x = 0; // assign 0 to x
- Don't confuse them.
- Java == is the same as mathematical =
previous |
start |
next