This may be a silly question for Java experts, but even for some one who has some years of Java experience like me, it is still an easily ignored topic. And even the senior developers on our team seem to make mistakes with these. I want to understand the operators on the Java Integer class. What is Java doing when comparing two Integers? For example, let's say we have Integer a and Integer b. Does Java do reference comparison or value comparison on ==, !=, <, >, <=, >= operators? And if one of the operator is an Integer and the other is a constant, what does Java do with ==, !=, <, <>, <=, >=? And if one of the operator is an Integer and the other is an int, what does Java do? In my experience, seems that Java does reference comparison with two Integers, and seems that it does value comparison with one Integer and one constant.
R
Raptor81
@Raptor81