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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. How to format Output and Input in Java
  2. Using ‘final’ Keyword in Java
  3. Java Classes and Objects Introduction
  4. Java Numbers Class
  5. Nested Class in Java
  6. Exception Handling in Java
  7. Basics of Java
  8. Java Loop Control
  9. Basics of Java Variables
  10. Java Applet Basics

You May Also Like

Primary Sidebar

Recent Posts

  • ncat Command Examples in Linux
  • ncat: command not found
  • nautilus Command Examples in Linux
  • namei: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright