Java Topics
Comments in Java
Last Updated : 26 May, 2026
title: Comments in Java
title: Comments in Java description: Java mein comments kaise likhte hain
Comments code mein notes hain jo compiler ignore karta hai. Code readable banane ke liye use hote hain.
3 Types of Comments
1. Single Line Comment
// Yeh ek single line comment hai
int age = 25; // age variable2. Multi-Line Comment
/*
Yeh ek
multi-line
comment hai
*/
int salary = 50000;3. Javadoc Comment
Documentation generate karne ke liye use hota hai.
/**
* Yeh method do numbers add karta hai.
* @param a pehla number
* @param b doosra number
* @return dono ka sum
*/
public int add(int a, int b) {
return a + b;
}Best Practices
- Code self-explanatory ho to comments kam likhein
- "Kya" nahi, "Kyun" explain karo
- Outdated comments update karte rahein
- Complex logic explain karo
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Comments in Java.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Java topic.
Search Terms
java, java programming, core java, java master course, java notes, master, course, fundamentals
Related Java Topics