Java Output / Print
Give your program a voice.
முக்கிய விளக்கங்கள் தமிழில் உள்ளன. Runnable example மற்றும் கூடுதல் practice notes ஆங்கிலத்தில் உள்ளன.
இந்தப் பாடத்தில்…
- Explain the key idea behind Output / Print.
- Read and run a complete example, then predict what changes.
- Recognize the topic-specific mistake discussed below.
அடிப்படையைப் புரிந்துகொள்ளுங்கள்
Output is how a small console program tells you what it is doing. print writes without adding a line break; println writes and then finishes the line. When debugging, print meaningful labels so you can connect an output value to the variable that produced it.
விரிவான விளக்கங்கள்
Text Print பண்றது எப்படி?
முந்தைய chapter-ல பார்த்தோம் — println() use பண்ணி values print பண்ணலாம்:
எத்தனை வேணும்னாலும் println() போடலாம். ஒவ்வொரு method-உம் new line-ல print ஆகும்:
Double Quotes
Text-ஐ double quotes-க்கு உள்ளே வையுங்கள்க்கணும்: "".
Quotes மறந்தா error வரும்:
print() Method
print()ன்னு ஒரு method இருக்கு — println() மாதிரியே ஆனா வித்தியாசம் ஒண்ணு இருக்கு.
Output-ஓட கடைசில new line add பண்றதில்ல — அடுத்த print அதே line-ல வரும்:
Readability-க்கு text-க்கு கடைசில ஒரு space போட்டா நல்லா இருக்கும்.
இந்த tutorial-ல println()-மட்டுமே use பண்றோம் — output-ஐ read பண்ண easy-ஆ இருக்கும்.
print vs println vs printf
| Method | Newline? | Best for |
|---|---|---|
print() | No | Same line output |
println() | Yes | One value per line |
printf() | No (%n use) | Formatted output |
System.out.print("Hello ");
System.out.println("World!"); // Hello World!
System.out.printf("Name: %s, Age: %d%n", "Alice", 25);
// Name: Alice, Age: 25
int x = 42;
System.out.println("Value: " + x); // concatenation
System.out.printf("Value: %d%n", x); // formatted`println()` மற்றும் `print()` -ல் என்ன முக்கிய வித்தியாசம்?
- println() faster-ஆக இருக்கும்
- println() output-க்கு கடைசில new line add செய்யும்
- print() strings மட்டும் print செய்யும்
- எந்த வித்தியாசமும் இல்லை
Reveal answer / விடை
println() output-க்கு கடைசில new line add செய்யும்
`println()` ஒவ்வொரு output-க்கும் கடைசில newline (\n) add செய்யும். `print()` அதே line-ல் தொடரும்.
முழுமையான உதாரணம்
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 {
System.out.print("Hello ");
System.out.println("Tamilan!");
System.out.printf("Completed: %d lessons%n", 4);
}
}Predict first. Then reveal the expected output / வெளியீடு
Hello Tamilan! Completed: 4 lessons
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
Change the first two calls to println and predict how many output lines there will be.
Reveal the answer and reasoning / விடை
The greeting now occupies two lines: Hello on one line and Tamilan! on the next. The completed count remains a separate third line.
தவிர்க்க வேண்டிய தவறு: print and println are case-sensitive names. println contains a lowercase letter l, not the number 1.
பாடத்தின் சுருக்கம்
- 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.