The Java Specification provides the following information about comments:
"There are two kinds of comments:
/* text */
A traditional comment: all the text from the ASCII characters /* to the ASCII characters */ is ignored (as in C and C++).
// text
An end-of-line comment: all the text from the ASCII characters // to the end of the line is ignored (as in C++)."
/* text */
A traditional comment: all the text from the ASCII characters /* to the ASCII characters */ is ignored (as in C and C++).
// text
An end-of-line comment: all the text from the ASCII characters // to the end of the line is ignored (as in C++)."
Here is an example of comments in the SimpleMath class that we have written already:
public class SimpleMath {
/*
This method just multiplies any integer by 2
and returns the result
*/
public int multiplyByTwo(int i){
//Should we check if i is bigger than 1/2 of Integer.MAX_VALUE ?
return i * 2; // The magic happens here
}
}
The comments do not affect the code in any way. They are just programmer's notes. Also, don't confuse them with JavaDoc or another documentation generating...