Home Javatutorials Java Comments - Java Tutorials



Java Comments - Java Tutorials
Posted on: April 18, 2011 at 12:00 AM
java comments

Comments in Java

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.

Types of comment

Java supports two kinds of comments :

Implementation Comment

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 Comment

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.

Example

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

  • The first comment style supports traditional C-language comments.
  • The second comment style supports single line C++ comments.
  • The third comment style is used by the javadoc documentation generation tool. 

 

 

Related Tags for Java Comments - Java Tutorials:


More Tutorials from this section

Ask Questions?    Discuss: Java Comments - Java Tutorials  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

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.