Skip to content

Instantly share code, notes, and snippets.

@bigwheel
Last active June 27, 2022 05:03
Show Gist options
  • Save bigwheel/ae4051f5b3c7e3934946cce4f7c43695 to your computer and use it in GitHub Desktop.
Save bigwheel/ae4051f5b3c7e3934946cce4f7c43695 to your computer and use it in GitHub Desktop.

6.8.1 Package Names

Names of packages that are to be made widely available should be formed as described in §7.7. Such names are always qualified names whose first identifier consists of two or three lowercase letters that name an Internet domain, such as com, edu, gov, mil, net, org, or a two-letter ISO country code such as uk or jp. Here are examples of hypothetical unique names that might be formed under this convention:

com.JavaSoft.jag.Oak
org.npr.pledge.driver
uk.ac.city.rugby.game

Names of packages intended only for local use should have a first identifier that begins with a lowercase letter, but that first identifier specifically should not be the identifier java; package names that start with the identifier java are reserved by Sun for naming Java platform packages.

When package names occur in expressions:

  • If a package name is obscured by a field declaration, then import declarations (§7.5) can usually be used to make available the type names declared in that package.
  • If a package name is obscured by a declaration of a parameter or local variable, then the name of the parameter or local variable can be changed without affecting other code.

The first component of a package name is normally not easily mistaken for a type name, as a type name normally begins with a single uppercase letter. (The Java programming language does not actually rely on case distinctions to determine whether a name is a package name or a type name.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment