
上QQ阅读APP看书,第一时间看更新
Comments
Although obvious and somewhat subjective, it is good practice to comment on code when it is not obvious why something is done, there is a complex routine, or there is a "kluge" added to work around a problem. In Java, there are two types of comments used, as well as a set of standards for JavaDoc. We will look at a couple of examples here:
There is an Oracle article on using comments in Java located at http://www.oracle.com/technetwork/java/codeconventions-141999.html#385.
- Block comment:
/* single line block comment */
code goes here...
/*
* multi-line block
* comment
*/
code goes here...
- End-of-line comment:
code goes here // end of line comment
- JavaDoc comments:
/**
* Description of the method
*
* @param arg1 to the method
* @param arg2 to the method
* return value returned from the method
*/
The Oracle documentation on using the JavaDoc tool is located at http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html.