Home> Java> JavaBase> body text

How to determine whether long type characters are equal in java

王林
Release: 2020-02-05 11:42:51
Original
5567 people have browsed it

How to determine whether long type characters are equal in java

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; }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!