For the Java programming language, there is no difference between the two. Java has two types of comments: traditional comments (/* ... */
) and end-of-line comments (// ...
). See the Java Language Specification. So, for the Java programming language, both /* ... */
and /** ... */
are instances of traditional comments, and they are both treated exactly the same by the Java compiler, i.e., they are ignored (or more correctly: they are treated as white space).
However, as a Java programmer, you do not only use a Java compiler. You use a an entire tool chain, which includes e.g. the compiler, an IDE, a build system, etc. And some of these tools interpret things differently than the Java compiler. In particular, /** ... */
comments are interpreted by the Javadoc tool, which is included in the Java platform and generates documentation. The Javadoc tool will scan the Java source file and interpret the parts between /** ... */
as documentation.
This is similar to tags like FIXME
and TODO
: if you include a comment like // TODO: fix this
or // FIXME: do that
, most IDEs will highlight such comments so that you don't forget about them. But for Java, they are just comments.