What is /** code for in the java language?

While I was messing around with netbeans using language java I did not understand what this command /** was for, I went behind and something appeared about Javadoc , I did not quite understand what this meant Could someone explain to me?

 20
Author: OnoSendai, 2014-02-20

2 answers

To insert comments into the source code, in Java one can use one of two ways:

// Comentário em uma única linha

/* Comentário
   que se divide em várias
   linhas
 */

When writing comments of the form (note the two asterisks in the first line)

/**
 *
 */

Comments can be interpreted by a tool - called Javadoc - that generates documentation based on the source code using, in addition to the comments between /** */, other special annotations, such as @author and @date, which provide, respectively, source information. authorship and the date of creation of the file.

The Wikipedia article provides a good sense of Javadoc.

The Java API is an example of documentation generated using the tool.

 16
Author: Beterraba, 2014-02-21 10:37:29

Complementing, follow some tags:

  • {@code} All text inside Keys is not interpreted, including text with HTML markup and Java tags
  • {@docRoot} contains the root directory of the generated documentation
  • @ deprecated indicates that the file or method is obsolete, discontinued, so its use is not indicated
  • @ exception is used to indicate the possible exceptions
  • @ throws is used to indicate the possible throws
  • {@link} do reference (link) to other documentation of some method
  • @ param is used to describe parameters
  • {@value} contains the value of a constant
  • @ version specifies the current version of the class or interface
  • @since specifies the version in which the method was included
 2
Author: Rafael Coelho, 2017-06-10 11:37:27