Adding Comments in Java
October 3rd, 2008A comment is a text that’s outside the normal flow. The computer doesn’t act on this comment. There are no instructions for the computer to perform inside this comment. Instead, the comment tells other programmers something about your code.
Comments are for your own benefits, too. Imagine that you set aside your code for a while and work on something else. When you return later to work on the code again, the comments help you remember what you were doing.
Java programming language has three kinds of comments:
1. Traditional Comments: This kind of comment begins with /* and ends with */. Everything between the opening /* and the closing */ is for human eyes only. Nothing between the /* and */ get translated by the compiler. Below is an example.
/*Your comment here
Another comment here
Another comment here*/
2. End-of-line Comments: An end-of-line comment starts with two slashes, and goes to the end of a line of type. Below is an example.
//This is an example of an end-of-line comment
3. Javadoc comments: A special javadoc comment is any traditional comment that begins with an extra asterisk. Below is an example.
/**
*This is a javadoc comment
*/


