This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "package / class name " Watch "package / class name " New topic
Author

package / class name

Frank Jacobsen
Ranch Hand

Joined: May 17, 2002
Posts: 353
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
Sheriff

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
Greenhorn

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: 353
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 !
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: package / class name