By Michael Burton

A package in Java is a way to organize Java classes into namespaces similar to modules. Each package must have a unique name for the classes it contains. Classes in the same package can access one another’s package-access members.

Java packages have a naming convention defined as the hierarchical naming pattern. Each level of the hierarchy is separated by ­periods. A package name starts with the highest-level domain name of the organization; then the subdomains are listed in reverse order. At the end of the package name, the company can choose what it wants to call the package. The package name com.dummies.­helloandroid is the name used in this example.

Notice that the highest-level domain is at the front of the package name (com). Subsequent subdomains are separated by periods. The package name traverses through the subdomains to get to the final package name of ­helloandroid.

A great example of another use for a package is having a Java package for all your web-related communications. Any time you need to find a web-related Java class, you can open that Java package and work on your web-related Java classes. Packages allow you to keep your code organized.