Java Tutorial

What is Java


Control Statements


Java Object Class


Java Inheritance


Java Polymorphism


Java Abstraction


Java Encapsulation


Java Array

Java OOPs Misc


Java Comments

The java comments are statements that are not executed by the compiler and interpreter. The comments can be used to provide information or explanation about the variable, method, class or any statement. It can also be used to hide program code for specific time.

Types of Java Comments

There are 3 types of comments in java.

  1. Single Line Comment
  2. Multi Line Comment
  3. Documentation Comment

1) Java Single Line Comment

The single line comment is used to comment only one line.

Syntax:

Flash Soon


Example:

Flash Soon


Output:

2) Java Multi Line Comment

The multi line comment is used to comment multiple lines of code.

Syntax:

Flash Soon


Example:

Flash Soon


Output:

3) Java Documentation Comment

The documentation comment is used to create documentation API. To create documentation API, you need to use javadoc tool.

Syntax:

Flash Soon


Example:

Flash Soon


Compile it by javac tool:

javac Calculator.java

Create Documentation API by javadoc tool:

javadoc Calculator.java

Now, there will be HTML files created for your Calculator class in the current directory. Open the HTML files and see the explanation of Calculator class provided through documentation comment.

Advertisement

Copyright ©2017 Design& develop