Page 408 - CITS - Computer Software Application -TT
P. 408
COMPUTER SOFTWARE APPLICATION - CITS
Creating User-defined Package
Java supports a keyword called “package” which is used to create user-defined packages in Java programming.
The general syntax to create a package is as:
package packageName;
Here, packageName is the name of package. The package statement must be the first line in a Java source code
file followed by one or more classes. For example:
package myPackage;
public class A {
// class body
}
In this example, myPackage is the name of package. The statement “package myPackage;” signifies that the
class “A” belongs to the “myPackage” package.
Naming Convention for User-defined Package in Realtime Project
While developing your project, you must follow some naming conventions regarding packages declaration. Let’s
take an example to understand the convention.
Look at the below a complete package structure of the project.
395
CITS : IT&ITES - Computer Software Application - Lesson 109 - 115 CITS : IT&ITES - Computer Software Application - Lesson 109 - 115