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

Asked

Viewed 622 times

20

While I was stirring the netbeans using language java I didn’t understand what that command was for /** , I went in and something came up about Javadoc, I didn’t quite understand what that meant someone could explain to me?

2 answers

16


To insert comments into the source code, in Java, you 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 - which generates documentation based on source code using, in addition to comments between /** */, other special notes, such as @author and @date, which provide, respectively, authorship information and the date of creation of the file.

The article from Wikiedia provides a good idea about Javadoc.

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

  • then this command only serves to comment more than one line?

  • @Nicolas Editei the answer giving more details

  • 1

    Interestingly, the /** is a mere /*, the extra * is only part of the "commented" text, and is ignored by Java like any other character that is inside the comment, until a */ . I mean, Javadoc’s 'staff" could have chosen /*#, /*{ or even /*JD, either makes the character, as long as it is within a multi-line comment (i.e., started by /*).

2

Complementing, follow some tags:

  • {@code} all text inside keys is not interpreted, including text marked HTML 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 serves to indicate possible exceptions
  • @throws serve to indicate possible throws
  • {@link} refers (link) to other documentation of some method
  • @param serves 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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.