1.8 Documentation with Comments

Suggested Skills: 4.B

LO 1.8.A — Describe the functionality and use of code through comments.

  • 1.8.A.1Comments are written for both the original programmer and other programmers to understand the code and its functionality, but are ignored by the compiler and are not executed when the program is run. Three types of comments in Java include /* */ (block comments), // (single-line comments), and /** */ (Javadoc comments used to create API documentation).

  • 1.8.A.2 — A precondition is a condition that must be true just prior to the execution of a method in order for it to behave as expected. There is no expectation that the method will check to ensure preconditions are satisfied.

  • 1.8.A.3 — A postcondition is a condition that must always be true after the execution of a 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.

Last updated

Was this helpful?