GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing docs.oracle.com — Naming a Package (The Java™ Tutorials > Learning the Java Language > Packages) Documentation
The Java™ Tutorials
Hide TOC
Trail: Learning the Java Language
Lesson: Packages Section: Creating and Using Packages The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available. Naming a PackageWith programmers worldwide writing classes and interfaces using the Java programming language, it is likely that many programmers will use the same name for different types. In fact, the previous example does just that: It defines a This works well unless two independent programmers use the same name for their packages. What prevents this problem? Convention. Naming ConventionsPackage names are written in all lower case to avoid conflict with the names of classes or interfaces. Companies use their reversed Internet domain name to begin their package names—for example, Name collisions that occur within a single company need to be handled by convention within that company, perhaps by including the region or the project name after the company name (for example, Packages in the Java language itself begin with In some cases, the internet domain name may not be a valid package name. This can occur if the domain name contains a hyphen or other special character, if the package name begins with a digit or other character that is illegal to use as the beginning of a Java name, or if the package name contains a reserved Java keyword, such as "int". In this event, the suggested convention is to add an underscore. For example:
About Oracle | Contact Us | Legal Notices | Terms of Use | Your Privacy Rights Copyright © 1995, 2024 Oracle and/or its affiliates. All rights reserved.
Previous page: Creating a Package
Next page: Using Package Members | ||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |