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
Author

Single type import error.

Avinash Talari
Greenhorn

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
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

Joined: Oct 27, 2005
Posts: 19723
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: Single type import error.