"SBC News" wrote:
> I've been using 'default package' sine I thought it default to NetBeans.
> So what you're saying is when I create a new project in NetBeans, I should
> give it a package name, so it does not create .java file in the 'default
> package', right?
Not really.
First of all, the "default package" is a /Java/ concept, not Netbeans. It
means a class that is not part of any package. It is for quick and dirty "toy"
classes, not for real work.
Second of all, "it" does not create .java files, /you/ create .java files.
Those are the source files that the programmer writes. The javac compiler
program then creates .class files from those.
Third of all, you don't "give [a project] a package name", you put individual
classes in packages. Packages organize and provide structure to groups of
classes, and have important consequences to method and instance variable
visibility. Consider, for example, the notion of "package-private", or
"default" access.
Fourth of all, these are fundamental notions to Java programming, and are a
little confusing because they relate to the directory structure where the
..java and .class files reside. It will give you large dividends to study the
Sun Java tutorial on the notions of classes and packages.
- Lew
|