Java Comments

Java comments are devided into three types

  1. Single-line Comments
  2. Multi-line Comments
  3. Document type Comments
Single-line Comments

Single-line comments start with two forward slashes (//). Any line starts with // java will ignore this line from the execution.


    // This is a comment
    System.out.println("Hello World");

    System.out.println("Hello World"); // This is a comment
  
Multi-line Comments

If we want to declare a comments at multiple lines then multi-line comments will be used, these comments start with /* and ends with */.


    /* The code below will print the words Hello World
    to the screen, and it is amazing */
    System.out.println("Hello World");
  
Document type Comments

document type comments start with /* and ends with */ and each line starts with *


    /* The code below will print the words Hello World
    * this is sample document type comment
    * to the screen, and it is amazing 
    */
    System.out.println("Hello World");