Skip to content
Advertisement

Importing two classes with same name. How to handle?

Say I’ve a code like:

JavaScript

Should I be full qualified class names? Can I get rid of the import statements? Is such a scenario common in real world programming?

Advertisement

Answer

You can omit the import statements and refer to them using the entire path. Eg:

JavaScript

But I would say that using two classes with the same name and a similiar function is usually not the best idea unless you can make it really clear which is which.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement