This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell 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


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "help in initializing wrapper objects" Watch "help in initializing wrapper objects" New topic
Author

help in initializing wrapper objects

Sugantha Jeevankumar
Ranch Hand

Joined: Jun 06, 2007
Posts: 93
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
Greenhorn

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;

Cheers,
[ December 11, 2007: Message edited by: Lucas Lech ]
 
GeeCON Prague 2014
 
subject: help in initializing wrapper objects