当前位置:网站首页>Long类型的相等判断
Long类型的相等判断
2022-07-03 09:02:00 【padDio】
今天做项目的时候一直跑不出想要的结果,最后才发现是一处判断语句出了问题。有两个Long类型的变量初始赋值都为10000,但用“==”来判断结果却是判断它们不相等。
Long中有⼀个静态的内部类LongCache,专门⽤于缓存-128⾄127之间的值,⼀共256个元素。如果值在[-128, 127]之间,会放在缓存⾥⾯,此时用“==”可以判断两个变量相等。⽽超过这个范围就要new⼀个新的对象,也就是说"=="不能判断对象是否相等。
后来改成equals()来判断,最终才运行成功。
边栏推荐
- Notes on numerical analysis (II): numerical solution of linear equations
- Save the drama shortage, programmers' favorite high-score American drama TOP10
- Integrated use of interlij idea and sonarqube
- MySQL installation and configuration (command line version)
- Windows安装Redis详细步骤
- Beego learning - JWT realizes user login and registration
- The "booster" of traditional office mode, Building OA office system, was so simple!
- 【点云处理之论文狂读经典版12】—— FoldingNet: Point Cloud Auto-encoder via Deep Grid Deformation
- 2022-2-14 learning the imitation Niuke project - send email
- LeetCode每日一题(1300. Sum of Mutated Array Closest to Target)
猜你喜欢

Principles of computer composition - cache, connection mapping, learning experience

2022-2-13 learn the imitation Niuke project - Project debugging skills

Utilisation de hudi dans idea

There is no open in default browser option in the right click of the vscade editor

Win10 quick screenshot

Using Hudi in idea

Alibaba cloud notes for the first time

NPM install installation dependency package error reporting solution

Introduction to the basic application and skills of QT
![[set theory] order relation (chain | anti chain | chain and anti chain example | chain and anti chain theorem | chain and anti chain inference | good order relation)](/img/fd/c0f885cdd17f1d13fdbc71b2aea641.jpg)
[set theory] order relation (chain | anti chain | chain and anti chain example | chain and anti chain theorem | chain and anti chain inference | good order relation)
随机推荐
On February 14, 2022, learn the imitation Niuke project - develop the registration function
LeetCode每日一题(745. Prefix and Suffix Search)
Simple use of MATLAB
Data mining 2021-4-27 class notes
LeetCode每日一题(1856. Maximum Subarray Min-Product)
Digital management medium + low code, jnpf opens a new engine for enterprise digital transformation
Jenkins learning (III) -- setting scheduled tasks
LeetCode每日一题(1996. The Number of Weak Characters in the Game)
[set theory] order relation (eight special elements in partial order relation | ① maximum element | ② minimum element | ③ maximum element | ④ minimum element | ⑤ upper bound | ⑥ lower bound | ⑦ minimu
Crawler career from scratch (V): detailed explanation of re regular expression
[solution to the new version of Flink without bat startup file]
[graduation season | advanced technology Er] another graduation season, I change my career as soon as I graduate, from animal science to programmer. Programmers have something to say in 10 years
Computing level network notes
LeetCode每日一题(2232. Minimize Result by Adding Parentheses to Expression)
Hudi integrated spark data analysis example (including code flow and test results)
Redis learning (I)
[point cloud processing paper crazy reading classic version 7] - dynamic edge conditioned filters in revolutionary neural networks on Graphs
【Kotlin学习】类、对象和接口——带非默认构造方法或属性的类、数据类和类委托、object关键字
Beego learning - Tencent cloud upload pictures
Flask+supervisor installation realizes background process resident