Path: csiph.com!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: Type conversions with the empty string Date: Mon, 13 Feb 2017 12:50:04 -0500 Organization: Aioe.org NNTP Server Lines: 35 Message-ID: References: NNTP-Posting-Host: PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:36253 On 1/31/2017 6:01 PM, Robert Klemme wrote: > On 31.01.2017 03:29, Arne Vajhøj wrote: >> On 1/30/2017 1:08 PM, Stefan Ram wrote: >>> Knute Johnson writes: >>>> On 1/28/2017 07:43, Stefan Ram wrote: >>>>> String.valueOf( 123 ) >>>> You would prefer any of those over Integer.toString(123)? >>> >>> »java.lang.String.valueOf« is the universal one-stop >>> solution to convert anything into a string, including >>> primitive values, class instances and even null! So it >>> does not make me think. Whenever I want to convert anthing >>> into a »java.lang.String« instance, I use this. >>> >>> »java.lang.Integer.toString« makes me thing about the type >>> of »123« and what the wrapper class of that type is, and >>> whether it really has such a method (for example, the static >>> »java.lang.Boolean.toString« method is only @since 1.4, >>> while »java.lang.Integer.toString« is @since 1.0.) >> >> Well - some actually like that type strictness. Including me. >> >> If something should be an int, then I prefer a compile time >> error if it suddenly is not an int any longer. > > Yes, but that would likely already be triggered by something more int > specific, e.g. an assignment or another method calls that needs to do > calculations with the value. Maybe. Maybe not. I don't mind double checking. Arne