Nearby lessons
9 of 125Java - Comments and Javadoc
- How to set up Java (PATH) on your computer
- How to write, save, compile and run your first program
- The meaning of every word in the main method
- The rules about class name and file name
- How to fix the common errors a beginner faces
Comments and Javadoc is a core concept of the Java language. This lesson explains Comments in Java and Comments and the javadoc Tool with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.
Comments in Java
Comments are notes written for humans (yourself or teammates). The compiler completely ignores them. There are three types:
Comments in Java
Comments and the javadoc Tool
We already saw the three comment types in Chapter 2. The special documentation comment (/** ... */) is used with the javadoc tool, which automatically creates HTML help documents (API documentation) for your classes.
On the command prompt, run:
Comments and the javadoc Tool
This creates a set of .html files — the same style of documentation pages you see on the official Java website.
- Six steps: install JDK → choose editor → write program → save file → compile with javac → run with java.
- File name must match the public class name exactly, and must end with .java.
- javac creates a .class file (bytecode); java runs it.
- public static void main(String[] args) is the entry point of every program.
- Comments (//, /* */, /** */) are ignored by the compiler and are used for documentation.
- Most beginner errors are due to PATH, folder location, or spelling mistakes.