File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Single type import error.

 
Avinash Talari
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
if(x=5){
sample1. A a = new sample1.A() ;
}
else{
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
Sheriff
Pie
Posts: 20393
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic