You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/java/packages.md
+19-3Lines changed: 19 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,15 @@ sidebar_label: Packages
6
6
7
7
#### The following convention should be followed for package naming:
8
8
9
-
The prefix of a unique package name is always written in all-lowercase ASCII letters and should be one of the top-level domain names, currently com, edu, gov, mil, net, org, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981.
9
+
The prefix of a unique package name is always written in **all-lowercase ASCII letters** and should be one of the top-level domain names, currently **com**, **org**,**edu**, **gov**, **mil**, **net**, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981.
10
+
11
+
- Packages are all lower case to avoid conflict with the names of classes or interfaces.
12
+
- Special characters are not allowed while naming packages, only alphanumeric.
13
+
- Avoid reserve keywords
10
14
11
15
Subsequent components of the package name vary according to an organization's own internal naming conventions. Such conventions might specify on technical aspect or a feature aspect e.g employee, leave, department, project etc :
12
16
13
-
14
-
#### packaging by feature
17
+
#### packaging by feature
15
18
16
19
- com.projectname.employee
17
20
- com.projectname.leave
@@ -28,3 +31,16 @@ Subsequent components of the package name vary according to an organization's ow
28
31
- com.projectname.factories
29
32
- com.projectname.utils
30
33
- com.projectname.repository
34
+
35
+
In some cases, the internet domain name may not be a valid package name.
36
+
This can occur if the domain name contains a hyphen or other special character,
37
+
if the package name begins with a digit or other character that is illegal to
38
+
use as the beginning of a Java name, or if the package name contains a reserved Java keyword, such as "int".
39
+
In this event, the suggested convention is to add an underscore. For example:
0 commit comments