Java Comments

Java Comments can be used to help for description the code. It will never show on run time.

Single-line comments



It starts with two forward slashes (//).

class HelloWorld
{
   public static void main(String args[])
   {
      // This is a comment
      System.out.println("Hello World!"); 
      System.out.println("Hello World"); // This is a comment 
   }
}

Java Multi-line Comments

More than one line comments start with /* and ends with */.
The comments with multi line start with /* and */ will be ignored by Java.

class HelloWorld
{
   public static void main(String args[])
   {
      /* These lines of message with multi line. 
      This with show in only source file.  */
      System.out.println("Hello World"); 
      /* This line of comment with single line. */
   }
}
java java tutorials learn java study java