However, use of the default package is a mistake, in anything other than a trivial one-class program. So maybe you should just ensure all your code is in a package.
So, exactly why is it a mistake?
If all the code is in one file, and all code in one file is considered to be in the same "default" package, then what's the difference between going with the default package and going through the trouble of defining your own package?
Is there an actual functional difference, or is it just considered "bad form" (i.e. the mark of a clueless n00b?)
As you know, the java.lang package is automatically imported. But what you might not realize is that the current package -- which might be the unnamed (default) package -- is also automatically imported. However, the unnamed package is not automatically imported if the current package is named.
So the problem with extending Test from your package mytest is that the unnamed package is not visible. And because it doesn't have a name, you can't import it.
To address MR Chen's question, this illustrates one reason for using packages. Another important consideration is in managing name spaces. (See this package section from Thinking in Java.) [ September 05, 2007: Message edited by: marc weber ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database