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

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reference to double ambigous" Watch "Reference to double ambigous" New topic

Reference to double ambigous

shanaya dutt

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

Joined: Jan 28, 2003
Posts: 4181

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.

Rob Spoor

Joined: Oct 27, 2005
Posts: 19849

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

How To Ask Questions How To Answer Questions
shanaya dutt

Joined: Jul 02, 2009
Posts: 23
I agree. Here's the link:
subject: Reference to double ambigous