• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Java – Documentation Comments

by admin

The Java language supports three types of comments:

  • /* text */ – The compiler ignores everything from /* to */.
  • //text – The compiler ignores everything from // to the end of the line.
  • /** documentation */ – This is a documentation comment and in general its called doc comment. The JDK javadoc tool uses doc comments when preparing automatically generated documentation.

What is Javadoc?

Javadoc is a tool that comes with JDK and it is used for generating Java code documentation in HTML format from Java source code, which requires documentation in a predefined format.

Following is a simple example where the lines inside /*….*/ are Java multi-line comments. Similarly, the line that precedes // is Java single-line comment.

Example:

/**
* The HelloWorld program implements an application that
* simply displays "Hello World!" to the standard output.
*
* @author  Singh is king
* @version 1.0
* @since   2018-02-12
*/
public class HelloWorld {

   public static void main(String[] args) {
      /* Prints Hello, World! on standard output.
      System.out.println("Hello World!");
   }
}

Following example makes use of * for heading and has been used for creating paragraph break:

Example:

/**
* <h1>Hello, World!</h1>
* The HelloWorld program implements an application that
* simply displays "Hello World!" to the standard output.
* <p>
* Giving proper comments in your program makes it more
* user friendly and it is assumed as a high quality code.
*
*
* @author  Singh is King
* @version 1.0
* @since   2018-03-12
*/
public class HelloWorld {

    public static void main(String[] args) {
        /* Prints Hello, World! on standard output.
        System.out.println("Hello World!");
    }
}

Filed Under: Java

Some more articles you might also be interested in …

  1. Java Field and Method Modifiers
  2. Java Inheritance
  3. Java Numbers Class
  4. Beginners Guide to Java Encapsulation and Subclassing
  5. Introduction to Java Packages
  6. Introduction to Java Inheritance
  7. Nested Class in Java
  8. Basics of Java Data Types
  9. Java Instance Methods
  10. Using ‘abstract’ Keyword in Java

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright