编程知识 cdmana.com

What data types does Java support

1) Four types of integers (byte、short、int、long):    byte:8 position , Used to represent the smallest unit of data , Such as the data in the file ,-128~127    short:16 position , Rarely used ,-32768 ~ 32767    int:32 position 、 The most commonly used ,-2^31-1~2^31  (21 Billion )    long:64 position 、 The second is often used    matters needing attention :    int i=5; // 5 It's called direct quantity ( Or literally ), namely Directly written constants .    The default value of the whole number is int type , So in the definition of long Type data followed by L or l.    Less than 32 The variable of the number of digits , Press int It turns out that .    Strong switches take precedence over mathematical operators . See examples in constants and variables .

 

2) Two types of floating-point numbers (float、double):    float:32 position , suffix F or f,1 Bit sign bit ,8 Bit index ,23 Bit effective mantissa .    double:64 position , The most commonly used , suffix D or d,1 Bit sign bit ,11 Bit index ,52 Bit significant tail    matters needing attention :    Two Into the system floating spot Count : 1010100010=101010001.0*2=10101000.10*2^10(2 Power )=1010100.010*2^11(3 Power )= . 1010100010*2^1010(10 Power )    mantissa :  . 1010100010   Index :1010   base :2    By default, all floating-point values are double type , So in the definition of float Type data followed by F or f;double Type can not write suffix , But in the calculation of decimals, be sure to write D or X.X    float  It's not as accurate as long high , Effective digits ( mantissa ) short .    float  The range is greater than long  The index can be big .    Floating point numbers are imprecise , You can't compare floating-point numbers exactly .

 

3) A character type (char):    char:16 position , It's an integer type , Enclosed in single quotation marks 1 Characters ( It can be a Chinese character ), Use Unicode The code represents the character ,0~2^16-1(65535) .    matters needing attention :    Not for 0 Characters .    Escape character :\n  Line break   \r  enter   \t Tab character   \" Double quotes   \\ It means a \    Two character char Intermediate use “+” Connect , Inside, the characters are converted into int type , And then add ,char The essence is number ! The binary , On display , after “ Handle ” Display as characters .

 

4) A boolean type (boolean):true really   and false false .

 

5) Type conversion :       char-->    Automatic conversion :byte-->short-->int-->long-->float-->double                   Coercive transformation :① Loss of accuracy , Produce errors , All numbers after the decimal point are discarded .② It is easy to exceed the value range .

 

6) memory :8 position :Byte( Byte type )          16 position :short( Short )、char( Character )          32 position :int( integer )、float( Single precision type / floating-point )          64 position :long( Long integer )、double( Double precision type )          the last one :boolean( Boolean type )

Based on my many years of working experience and learning experience , Recorded a new set of Java Focus on video tutorials , If you are learning now Java, At the beginning of learning Java There is no systematic learning course in the process , You can add groups 654631948 Collect the learning materials , Interview questions , Development tools, etc , There are senior people in the group java The teacher answers questions , Every day, there will also be live lectures on the basic part and architecture , You can also add my wechat renlliang2013 In depth communication , As long as I really want to learn Java People welcome .

java Basic course :https://ke.qq.com/course/149432?tuin=57912c43


Java Distributed Internet Architecture / Microservices / High performance /springboot/springcloud:

https://ke.qq.com/course/179440?tuin=57912c43

版权声明
本文为[renlianggee]所创,转载请带上原文链接,感谢

Scroll to Top