如何在不同的包中使用两个同名的类? [英] How to use two class with the same name in different packages?

查看:365
本文介绍了如何在不同的包中使用两个同名的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不同的包中访问两个具有相同名称的类?

How can I access two classes with the same name in different packages?

foo.bar.myClass.class

foo.myClass.class

所有这一切都在同一个班级

All of this in the same class

@TestRunner(Suite.class)
@SuiteTest({bar.myClass.class, myClass.class})

谢谢。

推荐答案

你必须导入一个和另一个你将写完全限定的路径

you will have to import one and other you will be writting fully qualified path

例如在你的代码中:

import foo.bar.myClass;

.
.
.
myClass ob; // this  will refer to foo.bar.myClass 
foo.myClass ob1 ;//this  will refer to foo.myClass

这篇关于如何在不同的包中使用两个同名的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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