Basic types (built-in type) Java data

(In order to facilitate memory, will contrast with the basic types of memory in C language)
in Java has eight basic data types (built-in type) are int, long, double, float,
byte, short, char, boolean took in every One type will be described:
1.int shaping
4 bytes in Java int, can store the data range is - 2 ^ 31 to 2 ^ 31--1
in the C language is true
Definitions: for Java, it one feature is the cross-platform operation. Therefore, it accounted for a few bytes of data types is a few bytes, not because of the different operating systems or operating system-digit change, while the C language will be affected by operating system
2.long long integer
in Java 8 bytes long, the data can be stored in the range -2 ^ 63 to 2 ^ 63--1
in the C language, different compilers may be four bytes, eight bytes may be
3.double double float
in Java double 8 bytes, because the floating-point number is stored in memory in a manner different from the integer store memory, it is not a simple 2 ^ n expressed
in C accounting for 8 double words section
4.float single precision floating point
in Java 4 bytes float
in the C language float 4 bytes
5.byte byte type
occupies one byte in Java byte, a small range of data that can be stored - 128 ~ 127
C language is not of this type
6.short short integer
2 bytes in Java short, the data may be stored in the range of - 2 ^ 15 to 2 ^ 15--1
The same is true in the C language
7.char character types
in Java char 2 bytes, indicates the range 0 ~ 65535, Unicode coding
in C char is 1 byte, the ASCII range is represented by 0 ~ 127, ASCII coding
8.boolean Boolean
in Java boolean type only two values, true for true, false indicates to false, and not an int in Java boolean conversion type, represent the absence of a true, 0 represents flase
EG: boolean bool1 = true;boolean bool2 = false;
C language does not have this type
in Java, the assignment can only be assigned within the range, otherwise it will error

Published 20 original articles · won praise 9 · views 908

Guess you like

Origin blog.csdn.net/weixin_44915811/article/details/101622947