![]() |
VOOZH | about |
In Java, comments are non-executable statements that explain code and improve readability. They are ignored by the compiler and do not affect program execution.
Java supports three main types of comments:
Single-line comments are used to comment on one line of code.
Syntax:
// Comments here( Text in this line only is considered as comment )
Single Line Comment Above
Multi-line comments are used to describe complex code or methods, as writing multiple single-line comments can be tedious.
/*
Comment starts
continues
continues...
Comment ends
*/
Multi Line Comments Below
Documentation comments are used to generate external documentation using Javadoc. They are generally used in professional projects to describe classes, methods, and parameters.
Syntax:
/**
* Comment start
* @param param-name description
* @return description
*/