Range instance code of integer value in Java

No more nonsense. I'll post the code directly to you. The specific code is as follows:

What is the reason?

  1。 When compiling Java, integer a = 100; Translated as - > integer a = integer valueOf(100);

  2。 The comparison is still the comparison of objects

  3。 In JDK source code

And

Here, in order to improve efficiency, Java initializes integer objects between - 128 -- 127, so the assignment is the same object in this range.

Add another sentence

summary

The above is the example code of the range of integer values in Java introduced by Xiaobian. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>