Java Object Value Of valueOf(final Object o)

Here you can find the source of valueOf(final Object o)

Description

value Of

License

Open Source License

Parameter

Parameter Description
o a parameter

Declaration

public static final String valueOf(final Object o) 

Method Source Code

//package com.java2s;

public class Main {
    public static final String STR_EMP = "";

    /**//  w w w  . j  ava  2 s .  c  o  m
     * 
     * @param o
     * @return
     */
    public static final String valueOf(final Object o) {
        return (o instanceof String) ? (String) o : (o == null ? "null" : o.toString());
    }

    /**
     * 
     * @param objs
     * @return
     */
    public static String toString(final Object[] objs) {
        if (objs == null) {
            return STR_EMP;
        }
        final int len = objs.length;
        if (len == 0) {
            return STR_EMP;
        }
        final StringBuilder buf = new StringBuilder(len * 12);
        for (int i = 0; i < len - 1; i++) {
            buf.append(objs[i]).append(", ");
        }
        return buf.append(objs[len - 1]).toString();
    }
}

Related

  1. valueOf(Object o)
  2. valueOf(Object o)
  3. valueOf(Object o)
  4. valueOf(Object obj)