Naming rules for Java packages

Time:2020-12-24

The packaging mechanism in Java is to limit the local program to one block in order to prevent the same name appearing in multiple places of the programIf there are people with the same name and surname in different areas, to solve this problem, we need to package all the people (programs) in different areas separately. Call a with A. A or B. a. So there’s no mistake. Packaging is actually a new folder, and then the need to package the program under this folder.

it is to be noted that​:

  1. Package must be the first executable line of code in the program
  2. A package statement can only have one sentence
  3. Package naming requires that theAll characters are lowercaseAt the same timeNo special characters are allowed
  4. Package can have multiple layersEach layer is separated by, for example, package china.hubei.wuhan China is a folder, Hubei is a folder under China, and Wuhan is a folder under Hubei
  5. After the package statementDon’t drop the semicolon。​
  6. The path of the package conforms to the definition of the developed system modules, such as production to production, material to material, basic class to basic class.
  7. If package is not used when defining a class, Java considers that the class we defined is located in theDefault packagePackage (default).

Individual project naming

  • indiIndividual projects refer to projects initiated by individuals but not completed by themselves, which can be public or private projects. Copyright mainly belongs toInitiator
    The package name is“Ini. Initiator name. Project name. Module name
  • onem: one man, recommendedindi, refers to projects initiated by individuals but not completed by themselves, which can be public or private projects. Copyright mainly belongs toInitiator
    The package name is“ONEM. Initiator name. Project name. Module name
  • persPersonal project refers to a project initiated by an individual, completed by himself and shared. Copyright mainly belongs topersonal
    The package name is“Per. Personal name. Project name. Module name
  • privPrivate project refers to a project initiated by an individual, completed by himself, and used privately. Copyright belongs topersonal
    The package name is“Priv. Personal name. Project name. Module name

Group project naming

  • team: team project refers to the project initiated and developed by the team, and copyright belongs to the team.
    The package name is“Team name. Project name. Module name
  • com: company project, copyright is owned by the company that initiated the project.
    The package name is“Com. Company name. Project name. Module name

(not original)