What are not 2 Long variables equal with == operator to compare in Java?
问题 I got a very strange problem when I'm trying to compare 2 Long variables, they always show false and I can be sure they have the same number value by debugging in Eclipse: if (user.getId() == admin.getId()) { return true; // Always enter here } else { return false; } Both of above 2 return values are object-type Long, which confused me. And to verify that I wrote a main method like this: Long id1 = 123L; Long id2 = 123L; System.out.println(id1 == id2); It prints true. So can somebody give me