Comments in Java
Written by
Suppose you have been coding for a long time. You suddenly want to look for a certain code but there are numerous class files accumulated on the screen.
You open a certain class file and realize you yourself could not recollect why was this code written.
To solve this problem, we have the concept of Comments in Java.
Comments are sentences written on a code which are not executed at all by the compiler.
It is meant solely for the programmer or other users to help them understand the code.
The three ways to give comments are:
Single Line Comment:
Given using ‘ // ’ before the comment line.
Example: Here the comment is ‘ This is my first program’.
Multi Line Comment:
Comment Line is enclosed between ‘ /* ‘ and ‘ */ ’.
Example:
Documenting Comment:
This kind of comment is used for documentation and enclosed between ‘ /** ’ and ‘ */ ’.