This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes help in initializing wrapper objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "help in initializing wrapper objects" Watch "help in initializing wrapper objects" New topic

help in initializing wrapper objects

Sugantha Jeevankumar
Ranch Hand

Joined: Jun 06, 2007
Posts: 92
In the following code snippet, the compiler shows error on both of the bolded lines

Why does this happen? But when I call the constructor using "new Double(9)" it works fine...Please help
Thanks in Advance.

SCJP 5.0
Lucas Lech

Joined: Dec 10, 2007
Posts: 23
Sometimes it can be useful to actually check the compiler error

first line gives you 'cannot convert from int to Double'
second one gives 'cannot convert from float to Double'

try this one:

Double myDouble = 9d;

[ December 11, 2007: Message edited by: Lucas Lech ]
It is sorta covered in the JavaRanch Style Guide.
subject: help in initializing wrapper objects
Similar Threads
Using java.util.Vector
Incorect operations order when implementing math parser with JavaCC
NaN reference
Why doesn't this match?