File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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 ]
I agree. Here's the link:
subject: help in initializing wrapper objects
It's not a secret anymore!