Using Comments in Java


Comments are ignored by the compiler but are invaluable for providing explanations or annotations within your code.

Source Code

// This is a single-line comment

/*
This is a multi-line comment
that spans over multiple
lines
*/

/**
 * This is a JavaDoc comment, which can be used to generate HTML documentation
 */

Use comments to explain the “why” behind complex logic, making your code easier to understand for others or for yourself when you return to it later.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments