开发者

How to use two class with the same name in different packages? [duplicate]

This question already has answers here: Importing two classes with same name. How to handle? (12 answers) Closed 7 years ago.

How can I 开发者_如何学JAVAaccess two classes with the same name in different packages?

foo.bar.myClass.class

and

foo.myClass.class

All of this in the same class

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

Thank you.


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

for example in your code:

import foo.bar.myClass;

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


You need to use the fully qualified names of the classes.

 foo.bar.myClass myvar;
 foo.myClass anothervar;


Without imports:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜