Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

When using binary operators with operands of different types, be aware of the implicit casts.
In particular (section 5.6.2, "Binary Numeric Promotion", from the java specification):

  1. If any of the operands is of a reference type, unboxing conversion is performed. Then:
  2. If either operand is of type double, the other is converted to double.
  3. Otherwise, if either operand is of type float, the other is converted to float.
  4. Otherwise, if either operand is of type long, the other is converted to long.
  5. Otherwise, both operands are converted to type int.

...