Alex Rivera | Logout

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

Asked 2011-04-24T00:27:02.667
39

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
Edit
Report

1 Answer

2

No. I think Java deliberately ditched typedef. The good news is, if you see a type, you know what it is. It can't be an alias to something else; or an alias to an alias to ...

If a new concept really deserves a new name, it most likely deserves a new type also.

The usage example of Sys=System will be frowned upon by most Java devs.

answered 2011-04-24T00:56:21.503

Your Answer