Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.9k points)

When trying to create package level Javadoc comments, whats the preferred method? What do you do?

package-info.java

  • Pros
    • Newer
  • Cons
    • Abuse of a class - Classes are for code, not for only comments

package.html

  • Pros
    • HTML extension means its not code
    • Syntax highlighting in IDE's/text editors
  • Cons
    • None?

For me, I've always used Package.html. But I'm wondering if its the correct choice.

1 Answer

0 votes
by (46k points)

package-info.java: "This file is new in JDK 5.0, and is preferred over package.html."—javadoc - The Java API Documentation Generator

Addendum: The big difference seems to be package annotations. There's a little more in the way of rationale in 7.4 Package Declarations.

Addendum: The annotation feature is also mentioned here and here.

Addendum: See also What’s package-info.java for?.

Related questions

0 votes
1 answer
asked Dec 2, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
0 votes
1 answer
asked Aug 25, 2019 in Java by Shubham (3.9k points)
0 votes
1 answer
asked Oct 17, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Oct 9, 2019 in Java by Anvi (10.2k points)

Browse Categories

...