我想知道java中的简单类型的取值范围,要求在java.sun.com官网的答案,感谢

解决方案 »

  1.   

    简单类型   大小    范围/精度float     4 字节  32位IEEE 754单精度double    8 字节   64位IEEE 754双精度byte      1字节 -128到127short     2 字节 -32,768到32,767int       4 字节 -2,147,483,648到2,147,483,647long      8 字节 -9,223,372,036,854,775,808到9,223,372,036, 854,775,807char      2 字节 整个Unicode字符集boolean   1 位   True或者false
      

  2.   

    经查 java.sun.com 没有关于这个的文章。 
      

  3.   

    经查 java.sun.com 没有关于这个的文章。 
      

  4.   

    答:你直接看最最权威的<<JAVA语言规范(英文版)>>不就行了(见第四章)--java.sun.com官网上有下载
      

  5.   

    要求在java.sun.com官网的答案?这样行不行:找API文档里关于基础类型的包装类的成员属性,如MAX_VALUE、MIN_VALUE、MIN_EXPONENT 、MAX_EXPONENT、NaN 等等都有。比如double类型的包装类就是Double类。
      

  6.   

    每个简单类型都有包装类型,从包装类型中可以获得简单类型的最大最小值。例如:int 对应的是 Integer,int 的最大最小值分别是 Integer.MAX_VALUE 和 Integer.MIN_VALUE。其它类型以此类推。
      

  7.   

    public final class Integer extends Number implements Comparable<Integer> {
        /**
         * A constant holding the minimum value an <code>int</code> can
         * have, -2<sup>31</sup>.
         */
        public static final int   MIN_VALUE = 0x80000000;    /**
         * A constant holding the maximum value an <code>int</code> can
         * have, 2<sup>31</sup>-1.
         */
        public static final int   MAX_VALUE = 0x7fffffff;...public final class Float extends Number implements Comparable<Float> {
    /**
         * A constant holding the largest positive finite value of type
         * <code>float</code>, (2-2<sup>-23</sup>)&middot;2<sup>127</sup>.
         * It is equal to the hexadecimal floating-point literal
         * <code>0x1.fffffeP+127f</code> and also equal to
         * <code>Float.intBitsToFloat(0x7f7fffff)</code>.
         */
        public static final float MAX_VALUE = 0x1.fffffeP+127f; // 3.4028235e+38f
     
        /**
         * A constant holding the smallest positive nonzero value of type
         * <code>float</code>, 2<sup>-149</sup>. It is equal to the
         * hexadecimal floating-point literal <code>0x0.000002P-126f</code>
         * and also equal to <code>Float.intBitsToFloat(0x1)</code>.
         */
        public static final float MIN_VALUE = 0x0.000002P-126f; // 1.4e-45f
    public final class Double extends Number implements Comparable<Double> {
    /**
         * A constant holding the largest positive finite value of type
         * <code>double</code>,
         * (2-2<sup>-52</sup>)&middot;2<sup>1023</sup>.  It is equal to
         * the hexadecimal floating-point li[code=Java]teral
         * <code>0x1.fffffffffffffP+1023</code> and also equal to
         * <code>Double.longBitsToDouble(0x7fefffffffffffffL)</code>.
         */
        public static final double MAX_VALUE = 0x1.fffffffffffffP+1023; // 1.7976931348623157e+308
    /**
         * A constant holding the smallest positive nonzero value of type
         * <code>double</code>, 2<sup>-1074</sup>. It is equal to the
         * hexadecimal floating-point literal
         * <code>0x0.0000000000001P-1022</code> and also equal to
         * <code>Double.longBitsToDouble(0x1L)</code>.
         */
        public static final double MIN_VALUE = 0x0.0000000000001P-1022; // 4.9e-324
    [/code]