Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: A small quiz Date: Thu, 01 Oct 2015 12:49:06 -0400 Organization: A noiseless patient Spider Lines: 21 Message-ID: References: <45bae432-2df5-4878-832b-11c465d666d8@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 1 Oct 2015 16:47:21 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="a78aad8b483612fbf45d18e918df0cca"; logging-data="20411"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xj8qf+nPGDqt3txDhgeYqqan8RErrYZI=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 In-Reply-To: <45bae432-2df5-4878-832b-11c465d666d8@googlegroups.com> Cancel-Lock: sha1:fiA9mwmxjzgihDKQFFszXkAXaqI= Xref: csiph.com comp.lang.java.programmer:32754 On 10/01/2015 11:59 AM, Eric Douglas wrote: > > So the valueOf is pointless? > I tried this little test program: > public static void main(String[] args) { > String s = null; > System.out.println(s); > System.out.println(String.valueOf(s)); > System.out.println(String.valueOf(null)); > } > It didn't crash until it tried to get the valueOf the constant. > It would have, hadn't PrintStream checked for a null. public void print(String s) { if (s == null) { s = "null"; } write(s); }