Java Comments

In this chapter you will learn:

  1. What are the three types of comment in Java
  2. How to use Java single line comment
  3. How to use Java multiline statement

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) {
  }//from w w  w.j a va 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 ww w  . j  av  a2 s  .  c  om
     is 
     a
     Multiline 
     comment.
  */
  public static void main(String[] argv) {
  }

}

Next chapter...

What you will learn in the next chapter:

  1. What is javadoc for
  2. Syntax for javadoc
  3. Example - Java documentation comment, Javadoc
  4. Javadoc tag list
  5. Example - More javadoc tags
Home »
  Java Tutorial »
    Java Langauge »
      Java Statement
Java if Statement
Java if else Statement
Java if else ladder statement
Java nested if statement
Java switch Statement
Java for loop
Java for each loop
Java while Loop
Java do while loop
Java break statement
Java continue statement
Java Comments
Java documentation comment(Javadoc)