Java Comments
Explain the why behind the code.
முக்கிய விளக்கங்கள் தமிழில் உள்ளன. Runnable example மற்றும் கூடுதல் practice notes ஆங்கிலத்தில் உள்ளன.
இந்தப் பாடத்தில்…
- Explain the key idea behind Comments.
- Read and run a complete example, then predict what changes.
- Recognize the topic-specific mistake discussed below.
அடிப்படையைப் புரிந்துகொள்ளுங்கள்
Comments are notes for readers; they do not produce output. Use them to explain decisions or constraints rather than repeat what a clear statement already says. A useful comment stays true when the code changes.
விரிவான விளக்கங்கள்
Java Comments என்னன்னு தெரியுமா?
Comments என்பது code-ஐ explain பண்ணவும், readable-ஆ வையுங்கள்க்கவும் use ஆகுது. Testing-ஓட போது சில code-ஐ skip பண்ணவும் use பண்ணலாம்.
Single-line Comments
Single-line comment //-ல ஆரம்பிக்கும்.
//-க்கு பக்கத்துல இருக்குற எல்லாத்தையும் Java ignore பண்ணும் — execute ஆகாது.
Code-க்கு முன்னாடி single-line comment எழுதலாம்:
அல்லது code-ஓட கடைசில போடலாம்:
Multi-line Comments
Multi-line comment /*-ல ஆரம்பிக்கும், */-ல முடியும்.
அந்த இரண்டுக்கும் நடுவுல இருக்குற எல்லாத்தையும் Java ignore பண்ணும்.
Code-ஐ explain பண்ண multi-line comment use பண்ணலாம்:
எது use பண்றது?Short comment-க்கு // — long explanation-க்கு /* */ use பண்றோம்.
// Single-line comment: Java இதை ignore பண்ணும்
int x = 10; // x-ல 10 store ஆகும்
/* Multi-line comment:
இந்த அணைத்தும் தெரியும்.
எதுவும் execute ஆகாது. */
System.out.println(x); // 10
// Tip: temporarily disable code
// System.out.println("Skipped line");Java-வில் multi-line comment எப்படி எழுதுவோம்?
- // இது comment
- # இது comment
- /* இது comment */
Reveal answer / விடை
/* இது comment */
`/* … */` என்பது Java-வின் multi-line comment syntax. `//` single-line, `/** */` JavaDoc-க்கு பயன்படுத்துவோம்.
முழுமையான உதாரணம்
This complete Main.java program focuses on the lesson idea. Reference fragments above may demonstrate individual statements; this example includes the imports, entry point, and supporting types it needs.
public class Main {
public static void main(String[] args) throws Exception {
// A welcome message for a new learner
System.out.println("Welcome!");
/* This comment can span
more than one line. */
System.out.println("Ready to practice.");
}
}Predict first. Then reveal the expected output / வெளியீடு
Welcome! Ready to practice.
The output shown was checked by running this complete example. Trace the executed statements in order, then compare with your run.
Change it. Run it. Understand it.
Load this lesson example into the editor. Change one value or statement, predict the result, then press RUN to execute Java.
Powered by OneCompiler. Code you run is sent to OneCompiler for execution. For Scanner examples, supply input in the editor I/O panel; for file examples, files exist in its execution environment.
நீங்களே முயற்சி செய்யுங்கள்
Practice challenge
Comment out the second println without deleting it.
Reveal the answer and reasoning / விடை
Add // before that statement. Only Welcome! will be printed.
தவிர்க்க வேண்டிய தவறு: Block comments cannot be nested. An early */ closes the current block comment.
பாடத்தின் சுருக்கம்
- Explain the example without reading the output first.
- Make the change requested in the practice task.
- Describe why the result changed—or why compilation failed.
Ready to move on? Follow the next lesson in course order, or return to the curriculum to review a prerequisite.