josh-cain
josh-cain

Reputation: 5226

Why are Java comments different colors in Eclipse?

I'm new to Eclipse and I'm using for some Android development. Eclipse is making me increasingly aware of poor habits I've formed (I.E. not capitalizing class names, etc.).

One thing I've noticed is that when I use the // characters to comment, the text turns green, but when I use the /** **/ characters, the text turns light blue. Is there a reason for this? Some type of comment specification that I missed somewhere? Are these supposed to serve as different functions for different types of comments?

I'm running Helios Service Release 1 (Build 20100917-0705) for Win 7(x64) if that makes any difference.

Upvotes: 5

Views: 7222

Answers (3)

Andy
Andy

Reputation: 5218

Eclipse comment defaults:

  • // and /* .. */ are standard comments and show up in one color, green
  • /** ...... **/ are javadoc comments and show up in a different color, blue

Upvotes: 5

developer
developer

Reputation: 9478

Nothing big reason behind this,

// means Single line comment

/** **/ means JavaDoc comments

Just to differtitte between them, the two different colors are given.

Upvotes: 3

Greg
Greg

Reputation: 33650

Block comments that start with /** in java are javadoc comments. Eclipse colors them differently to set them apart from normal comments.

Here's 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'll see a little 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 generate HTML documentation for your packages and classes. When you do this, the tool uses the javadoc comments in your source code to build the documentation.

Upvotes: 16

Related Questions