src/share/classes/java/lang/String.java

Print this page




2978      * @param   c   a <code>char</code>.
2979      * @return  a string of length <code>1</code> containing
2980      *          as its single character the argument <code>c</code>.
2981      */
2982     public static String valueOf(char c) {
2983         char data[] = {c};
2984         return new String(0, 1, data);
2985     }
2986 
2987     /**
2988      * Returns the string representation of the <code>int</code> argument.
2989      * <p>
2990      * The representation is exactly the one returned by the
2991      * <code>Integer.toString</code> method of one argument.
2992      *
2993      * @param   i   an <code>int</code>.
2994      * @return  a string representation of the <code>int</code> argument.
2995      * @see     java.lang.Integer#toString(int, int)
2996      */
2997     public static String valueOf(int i) {
2998         return Integer.toString(i, 10);
2999     }
3000 
3001     /**
3002      * Returns the string representation of the <code>long</code> argument.
3003      * <p>
3004      * The representation is exactly the one returned by the
3005      * <code>Long.toString</code> method of one argument.
3006      *
3007      * @param   l   a <code>long</code>.
3008      * @return  a string representation of the <code>long</code> argument.
3009      * @see     java.lang.Long#toString(long)
3010      */
3011     public static String valueOf(long l) {
3012         return Long.toString(l, 10);
3013     }
3014 
3015     /**
3016      * Returns the string representation of the <code>float</code> argument.
3017      * <p>
3018      * The representation is exactly the one returned by the
3019      * <code>Float.toString</code> method of one argument.
3020      *
3021      * @param   f   a <code>float</code>.
3022      * @return  a string representation of the <code>float</code> argument.
3023      * @see     java.lang.Float#toString(float)
3024      */
3025     public static String valueOf(float f) {
3026         return Float.toString(f);
3027     }
3028 
3029     /**
3030      * Returns the string representation of the <code>double</code> argument.
3031      * <p>
3032      * The representation is exactly the one returned by the




2978      * @param   c   a <code>char</code>.
2979      * @return  a string of length <code>1</code> containing
2980      *          as its single character the argument <code>c</code>.
2981      */
2982     public static String valueOf(char c) {
2983         char data[] = {c};
2984         return new String(0, 1, data);
2985     }
2986 
2987     /**
2988      * Returns the string representation of the <code>int</code> argument.
2989      * <p>
2990      * The representation is exactly the one returned by the
2991      * <code>Integer.toString</code> method of one argument.
2992      *
2993      * @param   i   an <code>int</code>.
2994      * @return  a string representation of the <code>int</code> argument.
2995      * @see     java.lang.Integer#toString(int, int)
2996      */
2997     public static String valueOf(int i) {
2998         return Integer.toString(i);
2999     }
3000 
3001     /**
3002      * Returns the string representation of the <code>long</code> argument.
3003      * <p>
3004      * The representation is exactly the one returned by the
3005      * <code>Long.toString</code> method of one argument.
3006      *
3007      * @param   l   a <code>long</code>.
3008      * @return  a string representation of the <code>long</code> argument.
3009      * @see     java.lang.Long#toString(long)
3010      */
3011     public static String valueOf(long l) {
3012         return Long.toString(l);
3013     }
3014 
3015     /**
3016      * Returns the string representation of the <code>float</code> argument.
3017      * <p>
3018      * The representation is exactly the one returned by the
3019      * <code>Float.toString</code> method of one argument.
3020      *
3021      * @param   f   a <code>float</code>.
3022      * @return  a string representation of the <code>float</code> argument.
3023      * @see     java.lang.Float#toString(float)
3024      */
3025     public static String valueOf(float f) {
3026         return Float.toString(f);
3027     }
3028 
3029     /**
3030      * Returns the string representation of the <code>double</code> argument.
3031      * <p>
3032      * The representation is exactly the one returned by the