How should one separate words in package names? Which of the following are correct?
com.stackoverflow.my_package
(Snake Case
using underscore)
com.stackoverflow.my-package
(Kebab Case
using hyphens)
com.stackoverflow.myPackage
(Camel Case
)
com.stackoverflow.MyPackage
(Pascal Case
)
What is the general standard?
All three are not the conventions.
Use com.stackoverflow.mypackage
.
The package names do not follow camel casing or underscores or hyphens package naming convention.
Also, Google Java Style Guide specifies exactly the same (i.e. com.stackoverflow.mypackage
) convention:
5.2.1 Package names
Package names are all lowercase, with consecutive words simply concatenated together (no underscores). For example, com.example.deepspace
, not com.example.deepSpace
or com.example.deep_space
.
— Google Java Style Guide: 5.2 Rules by identifier type: 5.2.1 Package names.