Why do we should use intValue() to compare?

The Integer.intValue() is used to get the primitive int value of Integer. The other test cases pass for you because the int values are low and the auto-unboxing feature of java does the value comparison for you. But for this one test case the int values are pretty large and hence it leads to object comparison instead of the value comparison which is not what we want.

Leave a Reply to Anonymous Cancel reply