Really? Not being a Java guy, what is the explanation for this?
Terms like boxing and reference comparison come to mind but I can't stitch them into a narrative to explain this.
Terms like boxing and reference comparison come to mind but I can't stitch them into a narrative to explain this.
https://stackoverflow.com/questions/1700081/why-is-128-128-f...
If you explicitly ask for a new object (Long a = new Long(123l);) you will get a new object and the comparison will fail as expected.
The moral of the story is to always use .equals().