int max=2147483647
int min=-2147483648
代码片段:
byte bmax, bmin;
short shmax, shmin;
char cmax, cmin;
int imax, imin;
long lmax,lmin;
float fmax,fmin;
double dmax,dmin;
fmax = Float.MAX_VALUE;
fmin = Float.MIN_VALUE;
dmax = Double.MAX_VALUE;
dmin = Double.MIN_VALUE;
bmax = Byte.MAX_VALUE;
bmin = Byte.MIN_VALUE;
cmax = Character.MAX_VALUE;
cmin = Character.MIN_VALUE;
shmax = Short.MAX_VALUE;
shmin = Short.MIN_VALUE;
imax = Integer.MAX_VALUE;
imin = Integer.MIN_VALUE;
lmax = Long.MAX_VALUE;
lmin = Long.MIN_VALUE;
System.out.println("float max="+fmax);
System.out.println("float min="+fmin);
System.out.println("double max="+dmax);
System.out.println("double max="+dmin);
System.out.println("byte max="+bmax);
System.out.println("byte min="+bmin);
System.out.println("char max="+cmax);
System.out.println("char min="+cmin);
System.out.println("short max="+shmax);
System.out.println("short min="+shmin);
System.out.println("int max="+imax);
System.out.println("int min="+imin);
System.out.println("long max="+lmax);
System.out.println("long min="+lmin);
输出:
float max=3.4028235E38
float min=1.4E-45
double max=1.7976931348623157E308
double max=4.9E-324
byte max=127
byte min=-128
char max=?
char min=
short max=32767
short min=-32768
int max=2147483647
int min=-2147483648
long max=9223372036854775807
long min=-9223372036854775808
说明:
实际上是每种类型的Container类定义的常量。
java中所有数字都是带符号的,没有unsigned,int在java中是固定的32bits,表示的范围为-2^31到2^31-1
:-2147483648 到2147483648
32位的带符号的
无符号的是0-2*2147483648