The statement that is used to create a package requires a
keyword called “package” and the following syntax.
Listing 1
The package definition must be the first statement of the
java program file. Suppose we have a program file named “Firstapplication.java”
and we want to put it inside a package called Example, then the coding that
would go inside is:
Listing 2
package Example;
public class Firstapplication
{
public static void main(String a[ ])
{
System.out.println("This is my first application");
}
}
If package statement is not specified, all the classes are
stored in a default unnamed package.