Writing comments are useful when you want to describe what a piece of code in you program does. This can make your code easier to understand for others who read your code or for yourself when you revisit your program after a long hiatus.
In JAVA, there are two types of comments:
- Single-line comments
- Multi-line comments
A single-line comment is used when your comment only spans one line. If you want to write a comment that spans multiple lines, then a multi-line comment should be the preferred choice.
Below is an example of a single-line comment. In this example, there are two single-line comments. One is placed on its own line and the other is placed inline with the print statement.
// this is a single-line comment
System.out.println("Hello World"); // another single-line comment
Below is what a multi-line comment looks like. A multi-line comment begins with the ‘/’ character followed…
View original post 44 more words