Writing Comments in Java
- How to write comments in Java?
- How to write single line comment in Java?
- How to write multi line comment in Java?
- How to write documentation comment in Java?
- What are the types of comments in Java?
- Comments are the statements which are never executed (i.e. non-executable statements).
- Comments are often used to add notes between source code so that it becomes easy to understand & explain the function or operation of the corresponding part of source code.
- Java Compiler doesn’t read comments; comments are simply ignored during compilation.
- There are 3 types of comments available in Java as follows;
- Single Line Comment
- Multi Line Comment
- Documentation Comment
- The documentation comment is used commonly to produce the javadoc for the respective program.
- The javadoc is generally HTML, if used in project it is a set of multiple HTML files describing each java program in the corresponding project.
- In the documentation comment we can add different notations such as author of the project or program, version, parameters required, information on results in return if any, etc.
- To add these notations, we have ‘@’ operator. We just need to write the required notation along with the ‘@’ operator.
- Some javadoc tags are;
- @author – To describe the author of the project.
- @version – To describe the version of the project.
- @param – To explain the parameters required to perform respective operation.
- @return – To explain the return type of the project.
Labels: Atul Palandurkar, Comments in Java, Core Java, Java, Java Tutorial