Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / December 2004

Tip: Looking for answers? Try searching our database.

Why is Double different from new Double()

Thread view: 
Bob Sparks - 30 Dec 2004 16:44 GMT
I have a method that requires a Number as an argument

If I do this

Double x = new Double("2");

numberMethod(x);

It doesn't compile with a not found error
nor does
numberMethod((Number)x);

where as

numberMethod(new Double(x));

does compile. Can any one explain it?

Bob
ByteCoder - 30 Dec 2004 17:00 GMT
> I have a method that requires a Number as an argument
>
[quoted text clipped - 15 lines]
>
> Bob

Could you display the error message?

Signature

-------------
- ByteCoder -           ...I see stupid people
-------------
                   Curiosity *Skilled* the cat

klynn47@comcast.net - 30 Dec 2004 17:05 GMT
Could you post the code and the error messages?
Ryan Stewart - 30 Dec 2004 19:07 GMT
>I have a method that requires a Number as an argument
>
[quoted text clipped - 4 lines]
>
> It doesn't compile with a not found error
My guess is your "x" has gone out of scope, but as others have said, post
some code. See:
http://www.physci.org/codes/sscce.jsp
Tony Morris - 30 Dec 2004 22:48 GMT
> I have a method that requires a Number as an argument
>
[quoted text clipped - 15 lines]
>
> Bob

Your problem description is incorrect.
Please state is correctly.
Also, state whether you are using a 1.5 or lower compiler.

Here's some trivia for the curious:
Does this compile on <=1.4 and/or 1.5? why (not)?

double[] d = new double[0].clone();

Signature

Tony Morris
http://xdweb.net/~dibblego/

Ryan Stewart - 30 Dec 2004 23:45 GMT
> Here's some trivia for the curious:
> Does this compile on <=1.4 and/or 1.5? why (not)?
>
> double[] d = new double[0].clone();

Well, first I'm interested in why it compiles without a cast. Second, I know
that some compilers used to think that cloning an array could throw a
CloneNotSupportedException. Is that what you're referring to?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.