JAVA 基础数据大小
2015-08-11 06:12
573 查看
计算机最小单位是 bit 位, 一位可以表示两种状态。
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. [
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.
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 Type | Default Value (for fields) |
---|---|
byte | 0 |
short | 0 |
int | 0 |
long | 0L |
float | 0.0f |
double | 0.0d |
char | '\u0000' |
String (or any object) | null |
boolean | false |
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.
相关文章推荐
- spring-hibernate 数据库出现乱码
- javacoo/CowSwing 丑牛迷你采集器
- javacoo/CowSwing 丑牛迷你采集器
- JSpider是一个用Java实现的WebSpider
- JSpider是一个用Java实现的WebSpider
- JAVA爬虫 WebCollector
- JAVA爬虫 WebCollector
- Nutch 是一个开源Java 实现的搜索引擎
- Nutch 是一个开源Java 实现的搜索引擎
- Struts2表单回显原理,struts2表单回显
- Spring中的转换器:Converter
- Java基础-IO流
- Spring问题
- Struts问题
- Ultra-Ptr 在eclipse中编译的办法
- eclipse 常用设置
- java实现文件的复制,移动
- IT技术:唯一ID高效率生成方式
- 利用JAVA线程安全队列简单实现读者写者问题。
- 尚硅谷公开课--struts2--4--struts2中扩展名的配置