Comments

There are three types of comments defined by Java.

  1. Single-line,
  2. Multiline and
  3. Documentation comment.

Single-line comment

Java single line comment starts from // and ends till the end of that line.


public class Main {
  // This is a single line comment.
  public static void main(String[] argv) {
  }

}

Multiline comment

Java multiline comment is between /* and */.


public class Main {
  /* This 
     is 
     a
     Multiline 
     comment.
  */
  public static void main(String[] argv) {
  }

}

Documentation comment.

Documentation comment is used to produce an HTML file that documents your program. The documentation comment begins with a /** and ends with a */.


public class Main {
  /** This 
      is 
      a
      documentation
      comment.
  */
  public static void main(String[] argv) {
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.