File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes package / class name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "package / class name " Watch "package / class name " New topic

package / class name

Frank Jacobsen
Ranch Hand

Joined: May 17, 2002
Posts: 358
In my book they say that its illegal tho have the same package and class name ???
I just tried it, and it compiled and worked fine !
Why this statement in my book ???
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

Which version of the JDK / which compiler are you using? I remember for a while this rule wasn't enforced, but I think it is now by newer compilers/jdks....
Blanka Li

Joined: Feb 18, 2002
Posts: 13
what book of yours?
I try it, and it works well.
here is the test code:
package Test;
public class Test
public static void main(String[] args)
System.out.println("Test OK!");
on jdk1.4.
Frank Jacobsen
Ranch Hand

Joined: May 17, 2002
Posts: 358
I use jdk 1.2 and it works also here !!!
I use the book "Complete Java 2 Certification study guide" from Simon Roberts Phillip Heller and Michael Ernest !
I agree. Here's the link:
subject: package / class name
It's not a secret anymore!