×

Html & Html5

The World's best Software Development Study Portal

Comments


  • Comments are basically for documentation purpose.
  • When we write code,for description of code we make use of comments.
  • Comments are ignored by compiler,these are like helping text in your program.

Types of Comments in Java:

  1. Single-line comment
  2. Multi-line comment

Single-line comment

Single-line comments are start with two forward slashes i.e.//. Whatever written inside // are ignored by compiler.It's only for user understanding.

Class Test{

Public Static Void main(String[]args)

{

//this is single line comment

System.out.println("hello youtube ");

}

}

Output:

output

Multi-line comment

Multi-line comments are start with /* and ends with */.Whatever written inside these are ignored by compiler.

Class Test{

Public Static Void main(String[]args)

{

/*this is multi line comment*/

System.out.println("hello youtube ");

}

}

Output:

output