34

Before Java methods we have something like:

/**
 * Takes a number and returns its square root.
 * @param x The value to square.
 * @return The square root of the given number.
 */
public float getSqrt(float x) {
...
}

Does this have a name (like docstrings in Python)?

tttppp
  • 7,723
  • 8
  • 32
  • 38

2 Answers2

35

Actually, they are called document comments and javadoc is a tool to generate those comments into HTML.

You can find the structure of the Javadoc comment in Wikipedia (for example).

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
7

Yup, it's called javadoc.

Riduidel
  • 22,052
  • 14
  • 85
  • 185
  • 7
    No, javadoc is the tool that processes them. They are called doc comments. – Sean Patrick Floyd Sep 16 '10 at 16:11
  • @seanizer that's obviously why pages generated using the javadoc tool are usually called "javadoc" and even why Eclipse and other IDEs have specific views called "Javadoc" used to display only those "doc comments". – Riduidel Sep 17 '10 at 08:09
  • hey, I call em JavaDocs myself, but it's not the official name. And the official document behind the link *you* supplied has the title "How to Write Doc Comments for the Javadoc Tool", not "How to Write Javadoc Comments" – Sean Patrick Floyd Sep 17 '10 at 08:19
  • @seanizer Well, to a certain extend, you are write, as it is the Sun name. However, the usage name for them is javadoc for the whole. Like we call Java the assembly of the Java Virtual Machine, the Java language, and the Java APIs. But that's only my point of view (and you are totally right to defend that opinion). – Riduidel Sep 17 '10 at 09:34
  • No, I agree with you. I use both the terms (Java and javadoc) the way you do. I was just nitpicking that the official name is different. :-) – Sean Patrick Floyd Sep 17 '10 at 09:40