Syntax

Java Write a Comment Syntax

In Java, write a comment: single-line, block and Javadoc comments — // line /* block */ /** Javadoc */

Quick Answer

Syntax
// line /* block */ /** Javadoc */
JavaSyntax

Write a Comment

Code example
// line /* block */ /** Javadoc */

Single-line, block and Javadoc comments.

Learn More

How to write a comment in Java

  1. Open your Java file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Java Write a Comment Syntax

Use // line /* block */ /** Javadoc */.

Related Syntax References

Frequently asked questions

What is the Java syntax for write a comment?

Use this pattern: // line /* block */ /** Javadoc */

Can I copy this Java code example?

Yes. Use Copy code and adapt the example to your program.

Is this Java syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify