package may not contain two members of the same name, or a compile-time error results. Here are some examples: Because the package java.awt has a subpackage image, it cannot (and does not) contain a declaration of a class or interface type named image. If there is a package named mouse and a member type Button in that package (which then might be referred to as mouse.Button), then there cannot be any package with the fully qualified name mouse.Button or mouse.Button.Click.
One class in Java cannot reside under two packages
I try to verify that and i'm not getting what was expected i.e no compile time error at all. Having a package, a class or a any member type in that package with the same name works fine. I would appreciate your insights regarding this. Thx.
Whatever doesn't kill us ...<br />Is probably circling back for another try.<br />SCJP 1.4
package may not contain two members of the same name, or a compile-time error results.
I believe "members" in above statement refer to member classes or interfaces. Therefore, two classes/interfaces with same name are not allowed in with in one package. For example following code will not compile:
The package name and class name could be same. Hope this helps. Barkat [ October 06, 2002: Message edited by: Barkat Mardhani ] [ October 06, 2002: Message edited by: Barkat Mardhani ]