您的位置:首页 > 编程语言 > Java开发

JAVA 基础数据大小

2015-08-11 06:12 573 查看
计算机最小单位是 bit  位, 一位可以表示两种状态。

 

JAVA中的基础数据有

 

byte: 字节     8 bit          【-128~127】  saving memory in large arrays

short:          16 bit         [ -32,768 ~ 32,767 ]

int :              32 bit        [ -231 ~ 231-1 ]  ;  in java SE 8  ,  an unsigned 32-bit integer, [ 0 ~ 232-1
]

long:            64 bit        [-263 ~263-1 ]  ;

float:           32 bit         a single-precision 32-bit IEEE 754 floating point

double:      64 bit        a double-precision 64-bit IEEE 754 floating point

boolean:      ?               its "size" isn't something that's precisely defined  1 boolean 不等于 1 bit

char:         16 bit          a single 16-bit Unicode character.  [
'\u0000'
(or 0)  ~ 
'\uffff'
(or 65,535) ]

 

the default value

Data TypeDefault Value (for fields)
byte0
short0
int0
long0L
float0.0f
double0.0d
char'\u0000'
String (or any object)  null
booleanfalse
 

Local variables are slightly different; the compiler never assigns a default value to an uninitialized local variable. If you cannot initialize your local variable where it is declared, make sure to assign it a value before you attempt to use it. Accessing
an uninitialized local variable will result in a compile-time error.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: