Top community members

Have you ever heard about encyclopedia for code?

What about: Wiki for Code project?

* because I've tried to share code and my solutions on different services and it was removed or I was unwelcomed
   - maybe it wasn't good place, but this one is.

if you think you have solution that can help someone, you are welcome to share this solution - Click here

Java - package naming convention

4 points
Asked by:
Bartek πŸ™‚
1078

Is there a correct way to name packages in java?

Can I use underscores or do I need to use capital letters like with class names?

My package names combinations:

example_loops_tests
exampleLoopsTests
ExampleLoopsTests
example.loops.tests

Which one is correct? Or there is more then 1 correct way to name packages in java?

1 answers
4 points
Answered by:
Bartek πŸ™‚
1078

From Oracle code convention:

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.
Subsequent components of the package name vary according to an organization's own internal naming conventions. Such conventions might specify that certain directory name components be division, department, project, machine, or login names.

Examples:

com.sun.eng
com.apple.quicktime.v2
edu.cmu.cs.bovik.cheese

9 - Naming Conventions

From google java style guide:

5.2.1 Package names
Package names are all lowercase, with consecutive words simply concatenated together (no underscores).

For example:

// correct:
com.example.deepspace

// incorrect:
com.example.deepSpace
com.example.deep_space

style guide - 5.2.1-package-names

0 comments Add comment

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey πŸ‘‹
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more