1.8 Documentation with Comments
1. Exam Points
- Identify
comments in a question.
- Understand the
three types of comments in Java.
2. Knowledge Points
(1) Comments(注释)
Comments are explanations for human readers.
- Comments are ignored by the compiler and are not executed when the program is run.
Types of comments:
- Single line comment : // comment
- Multi-line comment: /* comments */
- Javadoc: /** Javadoc */
(2) Precondition and Postcondition
Precondition
- Is a condition that must be true just
prior to the execution of a code segment/method in order for it to behave as expected.
Postcondition
- Is a condition that must always be true
after the execution of a code segment/method.
- Postconditions describe the outcome of the execution in terms of what is being returned or the current value of the attributes of an object.
3. Exercises