Why does Java comment on different colors in Eclipse?

I am new to Eclipse and I use Android for development. Eclipse makes me more aware of the bad habits that I have formed (IE does not capitalize class names, etc.).

One thing I noticed is that when I use the // characters for comments, the text turns green, but when I use the /** **/ characters, the text turns light blue. Is there a reason for this? Some kind of comment specification I missed somewhere? Do they assume that they perform different functions for different types of comments?

I am running Helios Service Release 1 (Build 20100917-0705) for Win 7 (x64), if that matters.

+4
source share
4 answers

Block comments starting with /** in java are javadoc comments. Eclipse distinguishes them differently to distinguish them from regular comments.

Here is a guide that discusses how to write documentation comments for java: http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html

When you hover over a class / method / field that has a javadoc comment in Eclipse, you will see a small documentation popup that contains a formatted version of the javadoc comment for that class / method / field.

You can also use the javadoc command-line tool to create HTML documentation for your packages and classes. When you do this, the tool uses javadoc comments in the source code to create documentation.

+16
source

The default value for Eclipse comments is:

  • // and /* .. */ are standard comments and are displayed in the same color, green
  • /** ...... **/ javadoc comments and are displayed in a different color, blue
+5
source

Nothing important for this

// means Single Comment

/ ** ** / means JavaDoc comments

Just to distinguish between them, two different colors are given.

+3
source

Normal comments like

 // this is a comment 

displayed in green
also look like multi-line comments that look like:

 /* This can spread out over more than one line.*/ 

Both are very useful, but when using the method / class in which they are located and want to know what it is doing, it will not appear just by hovering over the word.
Luckly java has a similar thing to do it

 /** This method creates a display */ 

This is called javadoc.

0
source

Source: https://habr.com/ru/post/1345028/


All Articles