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


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

Re: "Double.toString"

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: "Double.toString"
Date 2016-11-20 08:37 -0500
Organization A noiseless patient Spider
Message-ID <o0s8u2$rj6$1@dont-email.me> (permalink)
References <Double-toString-20161119164723@ram.dialup.fu-berlin.de>

Show all headers | View raw


On 11/19/2016 10:53 AM, Stefan Ram wrote:
>   When a course participant used the static method
>   »Double.toString«, I said it won't work this way,
>   because there is no such static method.
>
>   Turned out, a static »toString« method sits there
>   fat and happy on the documentation page of the class
>   »java.lang.Double«. And it does not even seem to be
>   new (no »since 1.8« or some such).
>
>   How could I have missed this method all those years?
>   Or did I know it once and my memory failed on me?
>
>   Have you been aware of this static toString method?
>   Is it a "well-known", prominent method to you?

     I wouldn't say "prominent," simply because I don't use it much:
Whenever I want Java's string version of a double, I usually want it
in combination with another string.  So I write

	System.out.println("\u03c0 \u2248 " + Math.PI);

... and let Java fill in the toString() method call.  However, I've
always been aware there's a method call involved, hence I've always
been aware of the existence of the called method.  (I confess to not
paying much attention to where the method call is made -- it's inside
StringBuilder somewhere, not in my code -- but the fact that the method
exists has always been plain to me.)

     FWIW, the method is listed in the oldest Java book I own: O'Reilly
"Java in a Nutshell, Second Edition" (1997, "updated for Java 1.1").

-- 
esosman@comcast-dot-net.invalid
"Nobody ever went broke underestimating the intelligence of the
American public." -- HLM (paraphrased)

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


Thread

Re: "Double.toString" Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-11-20 08:37 -0500
  Re: "Double.toString" Lothar Kimmeringer <news200709@kimmeringer.de> - 2016-11-20 22:49 +0100
    Re: "Double.toString" Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-11-21 08:25 -0500
    Re: "Double.toString" lewbloch@gmail.com - 2016-11-22 15:10 -0800
      Re: "Double.toString" Lothar Kimmeringer <news200709@kimmeringer.de> - 2016-11-24 14:07 +0100
        Re: "Double.toString" Arne Vajhøj <arne@vajhoej.dk> - 2016-11-24 11:12 -0500
        Re: "Double.toString" lewbloch@gmail.com - 2016-11-27 08:16 -0800
        Re: "Double.toString" Eric Douglas <e.d.programmer@gmail.com> - 2016-11-28 05:34 -0800

csiph-web