Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #36225

Re: Type conversions with the empty string

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Knute Johnson <nospam@rabbitbrush.frazmtn.com>
Newsgroups comp.lang.java.programmer
Subject Re: Type conversions with the empty string
Date Mon, 30 Jan 2017 11:34:27 -0600
Organization A noiseless patient Spider
Lines 33
Message-ID <o6ntbt$qko$1@dont-email.me> (permalink)
References <emtpy-string-20170128143107@ram.dialup.fu-berlin.de>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
Injection-Date Mon, 30 Jan 2017 17:32:45 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="c294840f8e49434e23fb5d763a96832a"; logging-data="27288"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187Te3YRW35hsfjwmn+uZrK"
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0
In-Reply-To <emtpy-string-20170128143107@ram.dialup.fu-berlin.de>
Cancel-Lock sha1:10MAJpg12YJybb7PeINguhuAA7c=
Xref csiph.com comp.lang.java.programmer:36225

Show key headers only | View raw


On 1/28/2017 07:43, Stefan Ram wrote:
>   There are actually two ways to convert »123« to a string
>   that both involve the empty string:
>
> ""+123
>
>   and
>
> "".valueOf( 123 )
>
>   , and both are frowned upon! But real problems in software
>   enginnering involve architecture or "logical" errors, seldom
>   small-scale wordings. What is the worst thing that could
>   happen when someone uses one of those? (That a beginner reading
>   the source might become confused?)
>
>   I'd say that
>
> "".valueOf( 123 )
>
>   is even more robust than
>
> String.valueOf( 123 )
>
>   because the former is still working when a file »String.class«
>   is found early enough in the class path.
>

You would prefer any of those over Integer.toString(123)?

-- 

Knute Johnson

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: Type conversions with the empty string Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-01-30 11:34 -0600
  Re: Type conversions with the empty string Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-01-30 12:25 -0600
  Re: Type conversions with the empty string Eric Douglas <e.d.programmer@gmail.com> - 2017-01-30 10:58 -0800
  Re: Type conversions with the empty string Arne Vajhøj <arne@vajhoej.dk> - 2017-01-30 21:29 -0500
    Re: Type conversions with the empty string Robert Klemme <shortcutter@googlemail.com> - 2017-02-01 00:01 +0100
      Re: Type conversions with the empty string Arne Vajhøj <arne@vajhoej.dk> - 2017-02-13 12:50 -0500

csiph-web