Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 is the difference between /* */ and /** */ comments in Java?
Multiline comments (/* */) are used to comment multiple lines in the source code.
Example
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
Documentation comments (/** */) are used to generate a documentation on the source code using the Javadoc tool.
Example
/**
* @author Tutorialspoint
*/
public class CommentsExample {
public static void main(String args[]) {
int num = 1;
System.out.println("value if the variable num: "+num);
}
}
Output
value if the variable num: 1
You can generate Java documentation of the above class using the Javadoc command as −
C:\Sample>javadoc CommentsExample.java
Advertisements