Java:导入与另一个导入语句冲突 [英] Java : The import collides with another import statement

查看:226
本文介绍了Java:导入与另一个导入语句冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将一个现有的Java应用程序导入到我的Workspace中. 我看到,在应用程序中的不同包中都存在一个同名类.

I have imported an Existing Java Application into my Workspace . I see that , a class with same name is present in different packages with in the Application.

例如,在

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

例如,当我尝试在一个类中同时使用它们时,如下所示

When I tried to use both of them within a class, for example as shown below

import com.tata.model.common.Status;
import  com.bayer.frontlayer.dao.Status;
public class Adapter
{

}

它开始在Eclipse中给出错误提示

It started giving an error in Eclipse stating

import com.bayer.frontlayer.dao.Status 与另一个import语句冲突

The import com.bayer.frontlayer.dao.Status collides with another import statement

有没有解决不改变类名的办法?

Is there anyway to solve this without changing the name of the classes??

谢谢.

推荐答案

您可以显式使用它们,而无需导入它们,因此所包含的软件包名称可以区分这两者:

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

这篇关于Java:导入与另一个导入语句冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆