javacodex.com
Java Examples
Java Examples
memu home questions

Commenting

The Java language supports three kinds of comments:

/* text */

The compiler ignores everything from /* to */.

/** documentation */

This indicates a documentation comment (doc comment, for short). The compiler ignores this kind of comment, just like it ignores comments that use /* and */. The JDK javadoc tool uses doc comments when preparing automatically generated documentation. For more information on javadoc, see the Java tool documentation.

// text The compiler ignores everything from // to the end of the line.

Source: (Comments.java)

class Comments {
 
   public static void main(String args[]) {
 
     // This is a one line comment
 
     /* Multiple line comment
        This kind of comment can cross many lines, and is 
        commonly used to "comment out" sections of code
     */
 
     /*
     System.out.println("Code commented out.");
     */
 
      int x;  // Comment after variable
 
      System.out.println("A bunch of comments");
 
   }
}

Output:

$ java Comments
A bunch of comments

Questions answered by this page:

How to use comments in java code? Types of comments in java. Syntax for commenting out multiple lines. How to comment out code in java?

Related Examples:


Contact: javacodex@yahoo.com