aspose file tools
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 The Software Craftsman this week in the Agile 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: 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

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