Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Java judge whether two Long objects are equal?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)05/31 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report