Daniele Daniele - 6 months ago 7
Java Question

What's the different types of comments in IntelliJ IDEA?

I've started yesterday to use IntelliJ IDEA for java programming, before I was using Eclipse.

I've noticed that there are two types of comments that this software uses (excluding the classic

//comment here
):


  • /* comment here */
    and it will be displayed in grey

  • /** comment here */
    and it will be displayed in green



what is the difference between the two? when should I use one, when the other?

Answer
/*.....*/

If you want to comment out multiple line you need to use the multi line comment.

If you want to provide proper documentation to your methods/variables you need to use documentation comments. Since there is a tool which comes with jdk, which will create a documentation for your classes.

/**
* This method is used to ...
*/
e.g  public void method()
{
//your logic
}

Also you can use it for variable too.

/**
* This variable is used for ...
*/
private static int s=99;