A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Android Security Essentials Live Lessons
this week in the
Java in General
Default and Subpackage
Joined: Feb 16, 2006
Jul 04, 2006 09:35:00
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?
author and iconoclast
Joined: Jul 08, 2003
Jul 04, 2006 10:02:00
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]
I agree. Here's the link:
subject: Default and Subpackage
access modifiers and inheritance
"The use of the default package is discouraged." Should I worry?
public methods in a package class
Is there a solution for it?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014