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


Groups > comp.lang.java.help > #935

Re: Q) Parsing Command-Line Arguments

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups alt.comp.lang.java, comp.lang.java.help, comp.sources.d
Subject Re: Q) Parsing Command-Line Arguments
Date Tue, 09 Aug 2011 07:50:50 -0700
Organization A noiseless patient Spider
Lines 21
Message-ID <j1rhgh$l7k$1@dont-email.me> (permalink)
References <6af59288-146e-46ae-8ec9-e5fab5b9f27c@y16g2000yqh.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Tue, 9 Aug 2011 14:50:57 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="21748"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WvC/1IY3E4oyVju6utnjLfBfIgayRffA="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0
In-Reply-To <6af59288-146e-46ae-8ec9-e5fab5b9f27c@y16g2000yqh.googlegroups.com>
Cancel-Lock sha1:MFU3MX5OBy6DJApko7pphaWQV0M=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.help:935 comp.sources.d:36

Cross-posted to 3 groups.

Show key headers only | View raw


On 8/9/2011 5:28 AM, Proud Japanese wrote:
>          double d1 = Double.valueOf(args[0]).doubleValue() ;
>          double d2 = Double.parseDouble(args[0]);

> Which one is more preferable?


The first one actually returns a Double, not a double.  It's equivalent to:

   double temp = Double.parseDouble( string );
   Double retVal = new Double( temp );

Since you then assign it to a double, you must then extract the double 
value again:

   double d1 = retVal.doubleValue();

That's three statements in place of one.  I'd prefer the second here.


Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Q) Parsing Command-Line Arguments Proud Japanese <hayato.fujimoto@yahoo.com> - 2011-08-09 05:28 -0700
  Re: Q) Parsing Command-Line Arguments markspace <-@.> - 2011-08-09 07:50 -0700
  Re: Q) Parsing Command-Line Arguments Roedy Green <see_website@mindprod.com.invalid> - 2011-08-09 09:52 -0700
  Re: Q) Parsing Command-Line Arguments Lew <lewbloch@gmail.com> - 2011-08-10 10:10 -0700
    Re: Q) Parsing Command-Line Arguments Lew <lewbloch@gmail.com> - 2011-08-10 16:34 -0700

csiph-web