zuai-logo

Documentation With Comments

Ethan Taylor

Ethan Taylor

5 min read

Listen to this study note

Study Guide Overview

This study guide covers Java commenting and documentation, including single-line, multi-line, and Javadoc comments. It explains the purpose of each comment type and demonstrates their usage within classes and methods. The guide also touches upon preconditions and postconditions within Javadoc comments.

Now, we will learn one of the most useful features of Java: commenting and documentation. This allows us to write clear code and understand it. This will also allow readers to understand our code. With comments, we are explaining our code in easy to use words. These comments will not be compiled by the Java compiler.

Types of Comments and Their Uses

There are three types of comments, two which have the same purpose and one that has a more specific use.

Single-Line and Multi-Line Comments

Single-line comments are comments that are on one line while multi-line comments (also called block comments) are comments that span multiple lines. These types of comments are for explaining sections of code that may not be self-explanatory, especially before loops or if-else statements. However, we do not c...

Question 1 of 7

What symbols are used to start a single-line comment in Java? 🤔

//

/*

/**