Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java : The import collides with another import statement

You can use them explicitly without importing them, so the included package name differentiates between the two:

 //No imports required!
public class Adapter
{
     private com.tata.model.common.Status x;
     private com.bayer.frontlayer.dao.Status y;
}

You can import just one of the classes and use the fully qualified name for the other one.

e.g.

import com.tata.model.common.Status;
//import  com.bayer.frontlayer.dao.Status;

class SomeClass{
    void someMethod(){
       new Status(); //  com.tata.model.common.Status
       new com.bayer.frontlayer.dao.Status(); //com.bayer.frontlayer.dao.Status
    }
}

Though I think it would be less confusing in your case if you just used the fully-qualified names for both classes.


Directly apply full Class Names wherever applicable. Eg-

public class SomeClass {

public someMethod() {

com.myapp.someotherpackage.Status = "something";

com.some.other.package.Status = "otherthing";

if(com.myapp.someotherpackage.Status == com.some.other.package.Status) {

}
....
}
}