Equal operator
2 answers
Due to the binary digital advertising rules described in the Java Language Specification, section 5.6.2. These rules apply to binary operations on various types of numbers. It says that:
If one of the operands is of type double, the other is converted to double.
+11
source to share
int
will be converted to double
when we compare int to double. see https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.21.1
+3
source to share