what a package should contain .java file or a .class file .i hope its a .class file but in jdk 1.4 i see that i had .java files in java package that we use to import various other packages like (example:import java.math.* this folder or package consists of .java files why can any one explain?
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:
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: