Comments
Purpose:
- To describe in natural language what the code is doing.
Mechanics:
/* This is a comment. */// This is also a comment./** This is a comment which will appear in the auto-generated documentation. */
Usage:
- Anything between /* */ or /** */ or following // is ignored by the Java compiler.
- Comments are crucial:
- At the top of the program. This program header comment
should contain:
- the program name
- your name
- the date of the last revision
- a description of the program: its major structure and breakdown
- At the top of each method. This method header comment
should contain:
- the class name and the method name
- the purpose of the method
- any complex or interesting points about the method, such as error conditions or special cases that may or may not be handled by the method.
- In the definition of a class or variable of any sort.
- At the top of the program. This program header comment
should contain:
Restrictions:
- Comments cannot be nested
email suggestions to: cs015tas@cs.brown.edu
