The best way to comment code in Java
Solution 1
I personally prefer to use JAutodoc plugin for commenting. Take a look at it. Its good.
Solution 2
Take a look at Javadoc
Javadocs can easily be generated in Eclipse. You can type /**
and it will autocomplete. You can also configure your code templates to automatically generate javadocs.
Solution 3
Select the method for which you want comments and press SHIFT, ALT and J together.
Take the time to learn about JavaDoc as well it's a very rich area for documenting your code.
Solution 4
By convention this is the way to do it:
/** Some comments about the function
*
* @param id the user ID
* @param username The user password
*
*/
public Connect(int id, String password)
{
}
If your method returns anything, you would add a `@return' followed by an explanation.
You IDE and the standard JavaDoc tool will be able to parse this.
Solution 5
There seems to be some confusion on this thread. The key sequence I use to generate javadoc comments is SHIFT+ALT+J not CTRL?
Wassim AZIRAR
https://www.malt.fr/profile/wassimazirar I am not looking for permanent contract (no need to contact me for that) I develop 💻 in .NET Core, JavaScript, Angular and React ⚛
Updated on June 04, 2022Comments
-
Wassim AZIRAR almost 2 years
What's the best way to comment code in Java, is there a way to generate the function name and the parameters automatically in Eclipse ?
For example I'm writting those comments manually :
// <summary> // Some comments about the function // </summary> // <param name="id">the user ID</param> // <param name="username">The user password</param> // <returns></returns> public Connect(int id, String password) { }
Thanks already.