• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Single type import error.

 
Avinash Talari
Greenhorn
Posts: 3
  • 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: 20546
56
Chrome Eclipse IDE Java Windows
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic