Skip to content


Comments in Java are notes that you can insert at various points in your code. They don't affect the execution of the code in any way, but they can be extremely helpful in explaining what certain parts of your code do, and why they do it. This can make your code easier to understand for both yourself and others who might work on your code in the future.

There are two types of comments in Java:

  1. Single-line comments: These start with // and only apply to the text on the same line. // This is a single-line comment int speed = 10; // This comment is at the end of a line of code

  2. Multi-line comments: These start with /* and end with */. They can span multiple lines. / This is a multi-line comment /

It's a good practice to comment your code regularly and clearly, especially when writing complex programs. In this guide, we will use comments extensively to provide additional details and explanation for various lines of code, enhancing your understanding of Java programming.

Additional Resources

W3 Schools - Comments