Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

syntactic sugar - java, is there a way we can import a class under another name

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.

We can do something like this in C#:

using Sys=System;

or Vb:

Imports Sys=System
question from:https://stackoverflow.com/questions/5767864/java-is-there-a-way-we-can-import-a-class-under-another-name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...