Java Programming Style Guide

Trailing Comments

Trailing comments are used to provide an explanation for a single line of code. Begin trailing comments with a double slash (//) and place them to the right of the line of code they reference.

Trailing comments are used to explain tricky code, specify what abbreviated variable names refer to, or otherwise clarify unclear lines of code.

In general, avoid the use of trailing comments. Instead rewrite tricky or unclear code, use meaningful variable names, and strive for self-documenting code.

Rationale

Trailing comments are a throwback to the days of assembly language programming where single lines of code were impossible to understand without the use of comments.

Modern programming languages like Java allow programmers to write self-documenting code using meaningful variable names, eliminating the need for trailing comments

ss = s1 + s2 + s3;     //add the three scores into the sum
a = float(ss) / x;     //calculate the mean of the scores

Note:
This is an example of the WRONG WAY to comment a program