This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Default and Subpackage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Default and Subpackage" Watch "Default and Subpackage" New topic
Author

Default and Subpackage

Allen Bandela
Ranch Hand

Joined: Feb 16, 2006
Posts: 128

Hi.
When I imported a class from a default package into a class in its sub package, I am getting a compile error.

I did this as import DefaultPackageClass;

Is this wrong?

Thanks,
Allen
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Yep, it's wrong. It's expressly disallowed in the language specification, perhaps to discourage you from using the default package for anything but trivial student programs.

Early Java compilers did allow this, but more recent ones don't.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Default and Subpackage