Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Daniele Futtorovic Newsgroups: comp.lang.java.programmer Subject: Re: StringBuilder.append and CharSequence Date: Fri, 27 Sep 2013 19:31:29 +0200 Organization: A noiseless patient Spider Lines: 19 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Injection-Date: Fri, 27 Sep 2013 17:31:36 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="6f9010336c08059d3af092c0462bb2e7"; logging-data="19420"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+mn9ja7SwC5L3l3gsuuRyw" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 In-Reply-To: Cancel-Lock: sha1:U65PF4b9t2e5Km7NGjXeYrNY0cc= Xref: csiph.com comp.lang.java.programmer:25375 On 2013-09-27 15:30, Andreas Leitgeb allegedly wrote: > Daniele Futtorovic wrote: >> I'd make the toString() as follows to be on the safe side: >> char[] cs = new char[ m_len ]; >> Arrays.fill( cs, m_ch ); >> return new String(cs); > > If this is the ONLY safe side, then there wouldn't be a point > in implementing a CharSequence in the first place for my task. Why not? The Standard API's StringBuilder#append(CharSequence), AFAICS, does not call toString() -- granted, the JavaDoc stipulates nothing to that effect. > The apparent point for CharSequence was, that it looked like a > vehicle to pass a number and a char into StringBuilder.append(). -- DF.