Home > Software engineering >  Can't understand what Javadoc is
Can't understand what Javadoc is

Time:04-02

I can't understand what 'Javadoc' is. I wanted to know the difference between the /** */ and /* */ comments in the first place.

When I saw the answer in here, It said something about HTML and APIs in java. It was totally confusing and I couldn't understand anything. I am just a beginner in Java, so please help me...

I saw that there was absolutely NO Difference when I used both of them. The compiler ignored both multiline comments when it was executed.

CodePudding user response:

Javadoc has nothing to do with the compiled code or any other runtime behaviour.

It's there so that the programmer can comment on the classes, variables and methods. All in-place, no external comments or files needed.

And when you have an IDE like Eclipse or IntelliJ, it will show these comments when you hover over the method call somewhere else.

Javadoc can also be read from the source code (.java classes) and compiled into HTML pages, just like all major Java documentation is.

Check this out, it's a pretty good overview: https://www.baeldung.com/javadoc

CodePudding user response:

The compiler will ignore both comments, yes. There is no difference in what the compiler does.

The difference is that you can use the Javadoc tool to turn Javadoc comments -- not normal comments -- into documentation like this. (Many IDEs, like Eclipse or IntelliJ, will also show documentation in this format, for example when you mouse over a method that you're calling.)

CodePudding user response:

Normal comments get deleted when compiling to class.
Javadocs don't stay in the code just like regular comments and can be used to automatically generate HTML docs that you can publish for people to understand your API for example.

Javadoc example:
https://docs.javacord.org/api/v/3.4.0/

  • Related