Java Comments - The Coding Shala
Home >> Learn Java >> Java Comments
Java Comments
In every programming, language comments are used for understanding the program. Comments are human-readable and ignored by the compiler. In Java there are three types of comments:
1. Single-line comments
2. Multi-line comments
3. Documentation comments
Single-line and Multi-line comments are often used in programs.
Single-Line Comments
Single-line comments are used to comment single in the program. Single-line comment starts from //.
Multi-Line Comments
Multi-line comments are used to comment more than one line at once. Using multi-line comments we can comment single line or a part of the program. Multi-line comments start with /* and end with */ and between this every line ignored by the compiler.
public class CommentsExample{ public static void main(String[] args){ System.out.println("Single line comment here"); //this is single line comment /* multi-line comment starts here int i = 0; ignored by compiler continue multi-line here end of multi-line comments */ System.out.println("Hello there"); } } <<<<<<<<<<<<Output>>>>>>>.. Single line comment here Hello there
Other Posts You May Like
Comments
Post a Comment