Suppose we have a package called com.example1
containing a Hello
class (along with other classes).
Then we have another package com.example2
also containing a Hello
class (obviously with different behaviour).
Now let's suppose we need every class in com.example1 and the Hello class in com.example2
import com.example1.*;
import com.example2.Hello;
Which one gets called in this case?
Hello hello = new Hello();
Or does this give a compile error?
This is just a theoretical question out of curiosity.
Since packages were created to avoid naming conflict, what happens when two packages contain two classes with the same name?