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

Summary of Java Common knowledge points (①)-data types

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

one。 Data types in Java

The variable is to request memory to store the value. That is, when you create a variable, you need to apply for space in memory.

The memory management system allocates storage space for variables according to the type of variables, and the allocated space can only be used to store that type of data. Therefore, by defining different types of variables, you can store integers, decimals, or characters in memory.

Two big data types of Java:

1. Built-in data types (basic data types)

1. Six numeric types (byte, short, int, long, float, double) + void

8 16 32 64 32 64 bit

two。 A character type char

16-bit Unicode character

3. A Boolean boolean

1 bit

two。 About Integer

For two non-new generated Integer objects, the comparison result is true if the values of the two variables are between 128and 127. if the values of the two variables are not in this interval, the comparison result is false.

Integer I = 100 false Integer j = 100 false system. Out.print (I = = j); / / System.out.print

When java compiles Integer I = 100;, it translates to Integer I = Integer.valueOf. The definition of valueOf of Integer type in java API is as follows. The number between-128and 127will be cached. When Integer I = 127, 127will be cached. The next time Integer j = 127 is written, it will be taken directly from the cache and will not be new.

Public static Integer valueOf (int I) {assert IntegerCache.high > = 127; 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

Internet Technology

Wechat

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

12
Report