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

Analysis of automatic packing and unpacking Source Code of Java

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Most people do not understand the knowledge points of this "Java automatic packing and unpacking source code analysis" article, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Java automatic packing and unpacking source code analysis" article.

What do you mean by packing & unpacking?

The process of converting an int primitive type to an Integer wrapper type is called boxing and vice versa.

First, look at the code public static void main (String [] args) {Integer a = 127,b = 127; Integer c = 128d = 128; System.out.println (a = = b); / / true System.out.println (c = = d); / / false}

I wonder if there is anyone who doesn't know why true and false appear in this code. This leads to the operation of Java boxing. We go to the analysis with questions.

Packing (valueOf ()) public static Integer valueOf (int I) {/ /-128127 if (I > = IntegerCache.low & & I = 127;} private IntegerCache () {}} public static Integer valueOf (int I) {if (I > = IntegerCache.low & & I)

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

Development

Wechat

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

12
Report