aspose file tools*
The moose likes Beginning Java and the fly likes Reference to double ambigous Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reference to double ambigous" Watch "Reference to double ambigous" New topic
Author

Reference to double ambigous

shanaya dutt
Greenhorn

Joined: Jul 02, 2009
Posts: 23
In my proogram im using
Arc2D.Double() creating an arc
and later
v = Double.parseDouble(line.trim());
for extracting the double values from a line.
the compiler gives the error

"Reference to Double is ambiguous,both classes java.awt.geom.arc2D and java.lang.Double match"

how do i correct this error?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

You apparently did a static import of Arc2D, creating an ambiguous reference between Arc2D.Double (since statically imported, now just Double) and the Double wrapper class. To fix it either don't import the static content of Arc2D or refer to the Double you are interested in using the fully qualified name java.lang.Double wherever you need to use it.


Steve
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

The import of Arc2D.Double doesn't need to be static; you can also import nested classes as follows:

Instead of using this import for Arc2D.Double and typing java.lang.Double fully, I would do it the other way around:
- change the import to java.awt.geom.Arc2D;
- use Double for java.lang.Double
- use Arc2D.Double for java.awt.geom.Arc2D.Double

Everybody who sees "Double" expects that to be java.lang.Double, and with the above naming you don't break that expectation.

Also, I'm a lazy git, and Arc2D.Double is shorter than java.lang.Double


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
shanaya dutt
Greenhorn

Joined: Jul 02, 2009
Posts: 23
thanks...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reference to double ambigous