Packages are used to organize your Java programs.
Putting your .java source-code files into a package is not required, but it is highly recommended. Even if you are just learning Java,
you should get into the habit of having a package declaration at the beginning of each .java file.
This example is trivial and doesn't really need the package declaration because there isn't much to organize, but it's recommended by Java experts that you get into the habit of using package declarations as early as you can.
Notice that I didn't have an "import" statement. This is because the package: "java.lang" is imported automatically.
In the example above, the class file must be named HelloWorld.java (this filename is case-sensitive).
Because of the package declaration, my .java file will be stored within a hierarchy of directories:
./src/com/kaydell/test/HelloWorld.java
Having a hierarchy here is over-kill, but it is essential in larger programs where you have a .java file for every public class and for every public inerface.
After compiling the .java file, a .class file is created. This can go different places depending upon the options that you specify. It can go into the same directory as the .java source-code, or it might go into another directory such as:
./bin/com/kaydell/test/HelloWorld.class
Hope that helps.
Kaydell
[ May 25, 2007: Message edited by: Kaydell Leavitt ]