aspose file tools*
The moose likes Java in General and the fly likes Single type import error. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Single type import error." Watch "Single type import error." New topic

Single type import error.

Avinash Talari

Joined: May 12, 2010
Posts: 3
i have jsp in which i am importing two different packages containing the same classes A and B.
import sample1.A;
import sample2.A;

i am creating an instance for the classes as below
sample1. A a = new sample1.A() ;
sample2. A a = new Sample2.A();

I am getting the below error when i compile.
reference to A is ambiguous, both class A in sample1 and A in sample2 match.

how do i resolve the error.?
Rob Spoor

Joined: Oct 27, 2005
Posts: 19543

Remove the imports. Those are only necessary to use "new A()" inside code without having to specify the package. But in your case both classes have the same name, so you will need to omit at least one of the imports and use the full class name (with package) in code - but you're already doing that.

How To Ask Questions How To Answer Questions
Consider Paul's rocket mass heater.
subject: Single type import error.
Similar Threads
Fresh SDK Install Won't Compile?
Is it possible to call a action of one war file from action of another war file?
two actionForms for one action class?
calling servlet from java in different paths
perl String find and replace - count ?