Question

Is there a way to use a shortened package name in Java if you have conflicting names?

For instance, instead of typing out com.domain.a.b, if the conflict is in com.domain.a, you can just say b.SomeClass instead of com.domain.a.b.SomeClass. C# has a feature similar to this.

Was it helpful?

Solution

No, you either use fully qualified names or short names. You're probably looking for obscuring

A simple name may occur in contexts where it may potentially be interpreted as the name of a variable, a type, or a package. In these situations, the rules of §6.5 specify that a variable will be chosen in preference to a type, and that a type will be chosen in preference to a package. Thus, it is may sometimes be impossible to refer to a visible type or package declaration via its simple name. We say that such a declaration is obscured.

If you follow Java naming conventions, you shouldn't really have any issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top