You can first obtain the value of the basic type long of the Long object through the .longValue() method and then compare it, but when we use longValue to compare, it is easy to forget that the latter wrapper class calls the longValue method. Therefore, it is best to use equals for comparison, or you can directly use .longValue() for comparison, or directly use the .longValue() method for comparison. Remember not to use == for comparison.
(Recommended learning: java video tutorial)
equals method is as follows:
public boolean equals(Object obj) { if (obj instanceof Long) { return value == ((Long)obj).longValue(); } return false; }
Recommended related tutorials: java introductory tutorial
The above is the detailed content of How to determine whether long type characters are equal in java. For more information, please follow other related articles on the PHP Chinese website!