JAVA basic data types and the classification and conversion of Bytes

1. java basic data types are eight kinds of 3 categories:
 Numeric - byte, Short, int, Long, a float, Double
 char - char
 Boolean -boolean

2. Eight types Number of Bytes

Types of Take up storage space
byte 1 byte / 8
short The 2-byte / 16-bit
int 4-byte / 32-bit
long 8-byte / 64-bit
float 4-byte / 32-bit
double 8-byte / 64-bit
boolean 1 byte / 8

NOTE:
values 1.boolean type only two kinds of true and false logic values, 1 and 0 will be used to represent after compilation, compiled while 1 and 0 only occupy a space, but the minimum processing unit of the computer data is 1 bytes, 1 byte is equal to 8, the actual storage space is: a least-significant bit stored in the other seven padded with 0, if the value is true, then the stored binary is: 0000 0001, if is false, then the stored binary as follows: 0000 0000 (where there is a variety of views, but I looked pleasing to the eye of a record, other self-search).
2. char will put none of the above table, because char character space occupied uncertain. In java follows:

 编码为:UTF-8
       			char为英文时占1个字节
				char为中文时占3个字节
	编码为:GBK
			char为英文或中文时都占2字节

3. The basic data types range from small to large range Sort:
byte <Short <char <int <Long <a float <Double
Notes:
(. 1) to a wide range of small Java can be automatically converted, from small to large-scale needs cast.
(2) java default integer int, float to double.
(3) boolean not participate in operations.

Welcome to a lot of communication Oh! ! ! ! ! ! !

发布了1 篇原创文章 · 获赞 1 · 访问量 66

Guess you like

Origin blog.csdn.net/weixin_44613100/article/details/104422354