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


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

Re: Q) Parsing Command-Line Arguments

From markspace <-@.>
Newsgroups alt.comp.lang.java, comp.lang.java.help, comp.sources.d
Subject Re: Q) Parsing Command-Line Arguments
Date 2011-08-09 07:50 -0700
Organization A noiseless patient Spider
Message-ID <j1rhgh$l7k$1@dont-email.me> (permalink)
References <6af59288-146e-46ae-8ec9-e5fab5b9f27c@y16g2000yqh.googlegroups.com>

Cross-posted to 3 groups.

Show all headers | 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