原因?

解决方案 »

  1.   

    晕,那我还要问为什么为什么字符串用String而不用CharString呢
      

  2.   

    String a="1"; //这个字符串的值是1
    把它专成Int就是 
    Int b=Integer.parseInt(a); //使用固定的包装类,没有什么原因,就这么用的.
      

  3.   

    Integer类里面的parseInt()方法,剩下的靠自己了:-) $%#@#$@%
        public static int parseInt(String s) throws NumberFormatException {
    return parseInt(s,10);
        }
    所调用的本类的带两个参数的parseInt方法:
        public static int parseInt(String s, int radix)
    throws NumberFormatException
        {
            if (s == null) {
                throw new NumberFormatException("null");
            } if (radix < Character.MIN_RADIX) {
        throw new NumberFormatException("radix " + radix +
        " less than Character.MIN_RADIX");
    } if (radix > Character.MAX_RADIX) {
        throw new NumberFormatException("radix " + radix +
        " greater than Character.MAX_RADIX");
    } int result = 0;
    boolean negative = false;
    int i = 0, max = s.length();
    int limit;
    int multmin;
    int digit; if (max > 0) {
        if (s.charAt(0) == '-') {
    negative = true;
    limit = Integer.MIN_VALUE;
    i++;
        } else {
    limit = -Integer.MAX_VALUE;
        }
        multmin = limit / radix;
        if (i < max) {
    digit = Character.digit(s.charAt(i++),radix);
    if (digit < 0) {
        throw NumberFormatException.forInputString(s);
    } else {
        result = -digit;
    }
        }
        while (i < max) {
    // Accumulating negatively avoids surprises near MAX_VALUE
    digit = Character.digit(s.charAt(i++),radix);
    if (digit < 0) {
        throw NumberFormatException.forInputString(s);
    }
    if (result < multmin) {
        throw NumberFormatException.forInputString(s);
    }
    result *= radix;
    if (result < limit + digit) {
        throw NumberFormatException.forInputString(s);
    }
    result -= digit;
        }
    } else {
        throw NumberFormatException.forInputString(s);
    }
    if (negative) {
        if (i > 1) {
    return result;
        } else { /* Only got "-" */
    throw NumberFormatException.forInputString(s);
        }
    } else {
        return -result;
    }
        }