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, 30 Jan 2017 21:29:16 -0500 Organization: Aioe.org NNTP Server Lines: 26 Message-ID: References: NNTP-Posting-Host: PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; 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.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:36232 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. Arne