java,有没有办法可以用另一个名字导入一个类 [英] java, is there a way we can import a class under another name

查看:183
本文介绍了java,有没有办法可以用另一个名字导入一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法可以用另一个名字导入一个类?
就像我有一个名为javax.C的类和另一个名为java.C的类一样,我可以在名称C1下导入javax.C并以名称C2导入java.C.

is there a way we can import a class under another name? Like if i have a class called javax.C and another class called java.C i can import javax.C under the name C1 and import java.C under the name C2.

我们可以在C#中做这样的事情:

We can do something like this in C#:

using Sys=System;

或Vb:

Imports Sys=System


推荐答案

否,在Java中没有类似的东西。您只能以原始名称导入类,并且必须为您不导入的所有内容使用完全限定名称(除了 java.lang 中的那些以及当前类的名称)包)。

No, there is nothing like that in Java. You can only import classes under their original name, and have to use the fully qualified name for all that you don't import (except those in java.lang and the current class's package).

这篇关于java,有没有办法可以用另一个名字导入一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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