- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are comments in Java language?
In general comments in any programming language helps make the source code readable, compiler neglects these comments.
Java supports three types of comments –
Single line comments − Using these you can comment single lines. The compiler ignores everything from // to the end of the line.
Multiline comments − Using these you can comment multiple lines. The compiler ignores everything from /* to */.
Documentation comments − This is a documentation comment and in general it’s called doc comment. The JDK Javadoc tool uses doc comments when preparing automatically generated documentation.
Example
Following example demonstrates the usage of all the three types of comments in Java.
/** * @author Tutorialspoint */ public class CommentsExample { /* Following is the main method here, We create a variable named num. And, print its value * */ public static void main(String args[]) { // Declaring a variable named num int num = 1; // Printing the value of the variable num System.out.println("value if the variable num: "+num); } }
Output
value if the variable num: 1
- Related Articles
- Comments in C++ Programming Language
- What are Comments in JavaScript?
- What are JSP comments?
- What are the comments in C#?
- Java comments.
- /** and /* in Java comments
- Executable Comments in Java
- Comments in Java\n
- Java documentation comments
- What is the difference between /* */ and /** */ comments in Java?
- What are the various types of comments in JavaScript?
- What are the platforms that support Java programming language?
- Types of Java comments.
- Java single line comments.
- Java multi-line comments

Advertisements