Java Documentation Comments

Published by Admin on

Java Documentation Comments - intechnologies.in

In This chapter explaining (Java Documentation Comments) Javadoc. Javadoc to generate useful documentation for Java code.

In Java three types of Documentation comments :−

Sr.No.CommentDescription
1./* Some Text */ The compiler ignores everything from /* to */.
2.//Some TextThe compiler ignores everything from // to the end of the line.
3./**
Some
documentation */
This is a documentation comment (doc comment). The JDK javadoc tool uses doc comments for automatically generated documentation.

What is Javadoc With Example?

Javadoc is a tool. Javadoc used for generating Java code documentation in HTML format from Java source code.

Example

/**
* This Is Multi-Line Comments
* <h1>Hello, World!</h1> you can use this type HTML tags for
* heading, <p>...</p> for paragraph.
* you can write here class description,author,version and since
*
* @author  Deepak Mali
* @version 1.0
* @since   2020-04-20 
*/
public class HelloWorld {
   public static void main(String[] args) {
      // This is Single-Line Comment.
      // print "Hello World!"
      System.out.println("Hello World!");
   }
}

All javadoc following Tags :-

TagDescriptionSyntax
@authorAdds the author of a class.@author name-text
{@code}Displays text in code font without interpreting the text as HTML markup or nested javadoc tags.{@code text}
{@docRoot}Represents the relative path to the generated document’s root directory from any generated page.{@docRoot}
@deprecatedAdds a comment indicating that this API should no longer be used.@deprecated deprecatedtext
@exceptionAdds a Throws subheading to the generated documentation, with the classname and description text.@exception class-name description
{@inheritDoc}Inherits a comment from the nearest inheritable class or implementable interface.Inherits a comment from the immediate surperclass.
{@link}Inserts an in-line link with the visible text label that points to the documentation for the specified package, class, or member name of a referenced class.{@link package.class#member label}
{@linkplain}Identical to {@link}, except the link’s label is displayed in plain text than code font.{@linkplain package.class#member label}
@paramAdds a parameter with the specified parameter-name followed by the specified description to the “Parameters” section.@param parameter-name description
@returnAdds a “Returns” section with the description text.@return description
@seeAdds a “See Also” heading with a link or text entry that points to reference.@see reference
@serialUsed in the doc comment for a default serializable field.@serial field-description | include | exclude
@serialDataDocuments the data written by the writeObject( ) or writeExternal( ) methods.@serialData data-description
@serialFieldDocuments an ObjectStreamField component.@serialField field-name field-type field-description
@sinceAdds a “Since” heading with the specified since-text to the generated documentation.@since release
@throwsThe @throws and @exception tags are synonyms.@throws class-name description
{@value}When {@value} is used in the doc comment of a static field, it displays the value of that constant.{@value package.class#field}
@versionAdds a “Version” subheading with the specified version-text to the generated docs when the -version option is used.@version version-text

Question :-

  • What is Javadoc?
  • What are the different types of comments?
  • How do you comment multiple lines in Java?
  • What is Java single-line comment?
  • What is Java documentation comment?

Related Links:-

Facebook
Twitter
Pinterest
LinkedIn
Instagram
Follow by Email
YouTube
Telegram
RSS
WhatsApp