How are packages declared?
How are packages declared?
Rating:
Packages are declared by using the package statement. The word package is a keyword in Java. The package statement is not technically needed to write a complete Java program. However, if it appears, it must be the first executable statement in the program. Only comments or white spaces are allowed before a package statement. There can be only one package declaration in a program. If no package declaration appears, the class will belong to the default package.
For example, the following source code file defines a class named ClassOne in the package named pack1:
public class ClassOne{
{
// body of class
}
This source file will be saved with the name ClassOne.java in the directory named pack1.
Rating:
Other articles
- What is a JAD file?
- What is the bitwise left shift operator?
- What is the equals() method?
- What is a JAR file?
- What is JDBC?
