Fix for 5015163, and my first webrev (original) (raw)

Rémi Forax forax at univ-mlv.fr
Fri Feb 6 22:33:56 UTC 2009


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.

No, I'm not endorsing the APIs provided, at least for now:-) there is room to debate what would be the best choice(APIs) to support the "joint", if we decided to add one. Is it more clear now ?

By the way, I've written 3 tests, one by class (String, StringBuilder, StringBuffer) Should I add them to the webrev ?

Sherman Rémi



More information about the core-libs-dev mailing list