Firstly I'm not a Java guy, but I came across what appears on the surface to be an inconsistency with the way imports work.
Say you have a file and in this file you have your main function and you have also defined a class Foo, now a different implementation of Foo also exists in a package. Suppose you want to use both versions in your functionality.
You cannot explicitly import Foo from it's package, i.e. import mypackage.Foo;
As this will result in a conflict with the class defined locally in the file, so an error is generated at compile time.
What you can do is import the entire package, i.e. import mypackage.*;
This will work and you can access Foo by using the fully qualified name, using the simple name will result in the use of the local Foo. The inconsistency I see is that whilst the former generates an error (you have imported a class and sole purpose of the import is to be able to use the simple name as opposed to the fully qualified name) the latter does not even result in a warning.
I would have thought that both cases would generate a warning i.e. you may be using the wrong class as it is defined in 2 places, or the import statement is redundant as use of the simple name will resolve to the locally defined class, not the imported one.
So my question is: Is there an underlying reason it is implemented in this way?
Yes it is an outlier case, I do understand that.