6 Feb
2009
6 Feb
'09
10:59 p.m.
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:-)