Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (1.5k points)
Can anybody tell me exact difference between  /** and /* comments in  Java.

Do we use both for the same or is there any major difference?

1 Answer

0 votes
by (7.2k points)

The difference between /**/ and /***/ in Java programming language is small yet quite distinct in that they are meant to serve different purposes. That is to say that they can not be mistaken to be used for one purpose only.

As for /**/, this is usually used for multi-line commenting, and that is why it is known as a multi-line comment. That means that you can use them when you find yourself needing to write comments in your Java code that spans more than one line. The difference between a multi-line comment and // is that a multi-line comment allows a developer to comment out only one line of code.

On the other hand, /***/ is known as documentation comment. It can also be written as doc comment and JDK Javadoc uses it to generate documentation. Javadoc is a documentation generator for Java language and it generates API documentation in HTML format from Java source code.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...