Conversation
Notices
-
Hey #java, is it possible to import two classes with the same name, if they have different namespaces?
-
@grdryn yes :) but then when you use them you'll need to fully qualify them every time
-
@aprilush thanks! :) it seems having an import statement for both (fully qualified), will still clash - prob with good reason, seems odd tho
-
@grdryn ah, it works if you import 1 of them & use the fully qualified name for the rest,or do not import any & just use the qualified names
-
@grdryn now that i think of it it's not odd;import=telling java where to look for a class name,if the same name has 2 paths it gets confused
-
@aprilush makes sense now, thanks! :) Reason I was importing both: one was renamed to have same name as other, so I renamed the import
-
@aprilush it felt odd for me because I had both fully qualified everywhere in the code but the imports were still clashing
-
@aprilush I guess it's also a good thing because when it errors, it reminds people to qualify one. 'import someclass as sc' might be nice :)
-
@grdryn others want it too :) http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000069.html
Gerard Ryan likes this. -
@grdryn if both have the same importance, it's better to not import any, just use the qnames; otherwise, import the one which is most used
Gerard Ryan likes this.
-