Search Logic Blocks

Friday, January 24, 2020

Java: Comments

When you work on bigger projects, more than one programmers might be needed and other projects also can reuse the classes / packages / methods etc. in their projects. Always the code is not obvious. To make it readable and understandable, comments are added in between the code, wherever explanation is required. The compiler ignores the comments altogether. There are 3 kinds of comments -

Single Line Comment - It starts with // and only line is ignored.
// This is pi value used in all math programs.
final double pi = 3.14;
Multi Line / Block Comment - It starts with /* and ends with */ and between those symbols - all text is ignored.

/* This code is commented
System.out.println("Done"); 
*/
Javadoc Comment - It starts with /** and ends with */ and each line will start with *. Javadoc is a tool with JDK that generates HTML documentation from comments written in source code.

/**
 * This comment goes to javadoc
 */
NOTE: We will talk about java doc implementation more later.

No comments: