java基础类型

Java基础类型

标签(空格分隔): 基本类型


整数类型

byte

1个字节 范围从-128到127

System.out.println(Byte.SIZE);
System.out.println(Byte.MAX_VALUE);
System.out.println(Byte.MIN_VALUE);     

results:8 127 -128

short

2个字节 范围从-2^15~2^15-1

System.out.println(Short.SIZE);
System.out.println(Short.MAX_VALUE);
System.out.println(Short.MIN_VALUE);

results:16 32767 -32768

int

4个字节 范围从-2^31~2^31-1

System.out.println(Integer.SIZE);
System.out.println(Integer.MAX_VALUE);
System.out.println(Integer.MIN_VALUE);

results:32 2147483647 -2147483648

long

8个字节 范围从-2^63~2^63-1

System.out.println(Long.SIZE);
System.out.println(Long.MAX_VALUE);
System.out.println(Long.MIN_VALUE);

results:64 9223372036854775807 -9223372036854775808

浮点型

float

4个字节 单精度
指数8位 尾数23位
精度6~7

  System.out.println(Float.SIZE);
  System.out.println(Float.MAX_VALUE);
  System.out.println(Float.MIN_VALUE);

results:32 3.4028235E38 1.4E-45

double

8个字节 双精度
指数11位 尾数52位
精度15~16

 System.out.println(Double.SIZE);
 System.out.println(Double.MAX_VALUE);
 System.out.println(Double.MIN_VALUE);

results:64 1.7976931348623157E308 4.9E-324

char类型

2个字节 范围从-2^15~2^15-1

  System.out.println(Character.SIZE);
  System.out.println((int) Character.MAX_VALUE);
  System.out.println((int) Character.MIN_VALUE);

results: 16 65535 0

boolean

1位 false or true

猜你喜欢

转载自www.cnblogs.com/yghapsp/p/9034227.html