Comments in Java holds the description or hint about the code or explanations of the methods, interfaces, classes, fields etc.
The question arises why we are using comments. The answer is very simple- with the help of these comment the coder or programmer find convenient to understand the logic of the program. The compiler ignore these comments and do not compile it.
Java supports two kinds of comments :
These comments are taken from C++ in Java which are delimited by /*...*/. These are use to describe the code implementation so that the code understanding becomes easy for others.
Document Comments are known as doc comment. Doc Comment are used to describe the code specification and about the whole program not just a snippet or a part of code implementation.
Given below example will give you a clear idea about comment :
/* This is a
multiline comment. */
// This is a single-line comment.
/** This is a
multiline javadoc comment */
/*
File header
*/
public class MainClass{
/**
This is a method
*/
public static void main(String[] argv){
// output
System.out.println();
}
}
Description of the Code
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Java Comments - Java Tutorials
Post your Comment