How does Java judge whether two Long objects are equal?
This article mainly introduces the relevant knowledge of "Java how to judge whether two Long objects are equal". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope that this article "how to judge whether two Long objects are equal or not" can help you solve the problem.
Throw the question: Long a = 4l trueLong long b = 4l false a = b / / long a = 128l politics long b = 128l
If the value of Long is between [- 127128], it is OK to use "= =" to judge whether it is equal. If it is not in this range, "= =" cannot be used. The reasons are explained as follows:
Public static Long valueOf (long l) {final int offset = 128; if (l > =-128 & & l