变量、常量及方法

2019-06-28  本文已影响0人  _Wizard

关于Java标识符的定义,需要注意以下几点:





修饰符 返回值类型 方法名(参数类型 参数名) {
    方法体
    return 返回值;
}

For type byte, the default value is zero, that is, the value of (byte)0.
For type short, the default value is zero, that is, the value of (short)0.
For type int, the default value is zero, that is, 0.
For type long, the default value is zero, that is, 0L.
For type float, the default value is positive zero, that is, 0.0f.
For type double, the default value is positive zero, that is, 0.0d.
For type char, the default value is the null character, that is, '\u0000'.
For type boolean, the default value is false.[/quote]

以上摘自《Java Language Specification Second Edition》CHAPTER 4

In java, an int is 32 bits. A byte is 8 bits.


类型名 类型意义 位数(bit) 默认值 最大值 最小值
byte 字节型 8 0 127(2^7-1) -128(-2^7)
short 短整型 16 0 32767(2^15-1) -32768(2^15)
int 整型 32 0 2147483647(2^31-1) -2147483648(2^31)
long 长整型 64 0 9223372036854775807(2^63-1) -9223372036854775807(2^63)
float 单精度浮点型 32 0.0f
double 双精度浮点型 64 0.0d
boolean 布尔型 1 false true(1) false(0)
char 字符型 16 \u0000 \uffff(65,53) \u0000(0)

上一篇 下一篇

猜你喜欢

热点阅读