Rémi Forax wrote:
Xueming Shen a écrit :
public String join(Object first, Object... elements) {
    if (elements.length==0)
        return String.valueOf(first);
    return new StringBuilder().join(this, first, elements).toString();
}

It does not look right to simply return String.valueOf(first); when elements size is 0, where is "this"?
"this" is the delimiter.

",".join("hello", "world") => "hello,world"

Thus it doesn't use "this" if there is only one argument.
oops, did not pay attention to the "deimiter part:-)

Reply via email to