Java Comments

Comments in Java

There are three types of comment supported in 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) {
  }//w  w  w .  j av a  2  s  .c  o  m

}

Multiline comment

Java multiline comment is between /* and */. Everything from /* through */ is ignored by the compiler.


public class Main {
  /* This //from w w w.  ja va 2 s  . co  m
     is 
     a
     Multiline 
     comment.
  */
  public static void main(String[] argv) {
  }

}




















Home »
  Java Tutorial »
    Java Language »




Java Data Type, Operator
Java Statement
Java Class
Java Array
Java Exception Handling
Java Annotations
Java Generics
Java Data Structures