有什么不对么,你看看下面String类的valueOf()系列static String valueOf(boolean b) 
          Returns the string representation of the boolean argument. 
static String valueOf(char c) 
          Returns the string representation of the char argument. 
static String valueOf(char[] data) 
          Returns the string representation of the char array argument. 
static String valueOf(char[] data, int offset, int count) 
          Returns the string representation of a specific subarray of the char array argument. 
static String valueOf(double d) 
          Returns the string representation of the double argument. 
static String valueOf(float f) 
          Returns the string representation of the float argument. 
static String valueOf(int i) 
          Returns the string representation of the int argument. 
static String valueOf(long l) 
          Returns the string representation of the long argument. 
static String valueOf(Object obj) 
 
很好用阿,你没有用到也不能说设计的不合理吧

解决方案 »

  1.   

    忘了说一点:在反编译后的代码里经常是这样的语句:String.valueOf(String),我就搞不懂了!
      

  2.   

    String.valueOf(String)和String valueOf(Object obj) 应该差不多吧
    在java里把String也看成Object 。
    但我感觉这句话没什么用处。
    不要也可以。关注ing!!!!!!!!!
      

  3.   

    可能你的反编译器有问题,String.valueOf(Object obj) = obj.toString();
      

  4.   

    String str = String.valueOf(Object obj);
    String str = Object.toString();
    两个方法类似,只是前者的Object可以为null,后者不行
    前者是String这个类的valueOf()方法
    后者是Object的方法,如果Object为null,那更本就没有方法
      

  5.   

    相当于DELPHI中的IntToStr()、FloatToStr()吧
      

  6.   

    这个方法可以将Object参数或基本类型参数转换成String类型
      

  7.   

    String.valueOf()是把java的原始数据类型或运用多态产生的Object类型转为String类型,以下是sun的String类的各valueOf()方法的源码,好好看看吧!
        /**
         * Returns the string representation of the <code>Object</code> argument. 
         *
         * @param   obj   an <code>Object</code>.
         * @return  if the argument is <code>null</code>, then a string equal to
         *          <code>"null"</code>; otherwise, the value of
         *          <code>obj.toString()</code> is returned.
         * @see     java.lang.Object#toString()  
         */
        public static String valueOf(Object obj) {
    return (obj == null) ? "null" : obj.toString();
        }    /**
         * Returns the string representation of the <code>char</code> array
         * argument. The contents of the character array are copied; subsequent 
         * modification of the character array does not affect the newly 
         * created string. 
         *
         * @param   data   a <code>char</code> array.
         * @return  a newly allocated string representing the same sequence of
         *          characters contained in the character array argument.
         */
        public static String valueOf(char data[]) {
    return new String(data);
        }    /**
         * Returns the string representation of a specific subarray of the 
         * <code>char</code> array argument. 
         * <p>
         * The <code>offset</code> argument is the index of the first 
         * character of the subarray. The <code>count</code> argument 
         * specifies the length of the subarray. The contents of the subarray 
         * are copied; subsequent modification of the character array does not 
         * affect the newly created string. 
         *
         * @param   data     the character array.
         * @param   offset   the initial offset into the value of the
         *                  <code>String</code>.
         * @param   count    the length of the value of the <code>String</code>.
         * @return  a newly allocated string representing the sequence of
         *          characters contained in the subarray of the character array
         *          argument.
         * @exception NullPointerException if <code>data</code> is 
         *          <code>null</code>.
         * @exception IndexOutOfBoundsException if <code>offset</code> is 
         *          negative, or <code>count</code> is negative, or 
         *          <code>offset+count</code> is larger than 
         *          <code>data.length</code>.
         */
        public static String valueOf(char data[], int offset, int count) {
    return new String(data, offset, count);
        }
        /**
         * Returns the string representation of the <code>boolean</code> argument. 
         *
         * @param   b   a <code>boolean</code>.
         * @return  if the argument is <code>true</code>, a string equal to
         *          <code>"true"</code> is returned; otherwise, a string equal to
         *          <code>"false"</code> is returned.
         */
        public static String valueOf(boolean b) {
    return b ? "true" : "false";
        }    /**
         * Returns the string representation of the <code>char</code> 
         * argument. 
         *
         * @param   c   a <code>char</code>.
         * @return  a newly allocated string of length <code>1</code> containing
         *          as its single character the argument <code>c</code>.
         */
        public static String valueOf(char c) {
    char data[] = {c};
    return new String(0, 1, data);
        }    /**
         * Returns the string representation of the <code>int</code> argument. 
         * <p>
         * The representation is exactly the one returned by the 
         * <code>Integer.toString</code> method of one argument. 
         *
         * @param   i   an <code>int</code>.
         * @return  a newly allocated string containing a string representation of
         *          the <code>int</code> argument.
         * @see     java.lang.Integer#toString(int, int)
         */
        public static String valueOf(int i) {
            return Integer.toString(i, 10);
        }    /**
         * Returns the string representation of the <code>long</code> argument. 
         * <p>
         * The representation is exactly the one returned by the 
         * <code>Long.toString</code> method of one argument. 
         *
         * @param   l   a <code>long</code>.
         * @return  a newly allocated string containing a string representation of
         *          the <code>long</code> argument.
         * @see     java.lang.Long#toString(long)
         */
        public static String valueOf(long l) {
            return Long.toString(l, 10);
        }    /**
         * Returns the string representation of the <code>float</code> argument. 
         * <p>
         * The representation is exactly the one returned by the 
         * <code>Float.toString</code> method of one argument. 
         *
         * @param   f   a <code>float</code>.
         * @return  a newly allocated string containing a string representation of
         *          the <code>float</code> argument.
         * @see     java.lang.Float#toString(float)
         */
        public static String valueOf(float f) {
    return Float.toString(f);
        }    /**
         * Returns the string representation of the <code>double</code> argument. 
         * <p>
         * The representation is exactly the one returned by the 
         * <code>Double.toString</code> method of one argument. 
         *
         * @param   d   a <code>double</code>.
         * @return  a newly allocated string containing a string representation of
         *          the <code>double</code> argument.
         * @see     java.lang.Double#toString(double)
         */
        public static String valueOf(double d) {
    return Double.toString(d);
        }