💬 What Are Comments?
Comments are notes in the code that are ignored by the compiler.
They help explain what the code is doing and improve readability.
🧾 Types of Comments in Java
Type | Syntax | Use Case |
|---|---|---|
Single-line |
| For short, quick notes |
Multi-line |
| For longer explanations or block notes |
🟥 Single-line Comment
Starts with // and continues to the end of the line.
// This is a single-line comment
System.out.println("Hello Java"); // Inline comment📝 Multi-line Comment
Spans multiple lines — useful for detailed descriptions or disabling code.
/*
This is a multi-line comment.
It can be used to explain logic or temporarily disable code.
*/
System.out.println("Learning Java!");Learning Java!✅ Recap
Use
//for short explanationsUse
/* */for multi-line comments or block disabling