Java Break/Continue — தமிழ்

</>Coding Tamilan.← Java course & curriculum
Java Masterclass · Lesson 17 / 50 · தமிழ்

Java Break/Continue

Stop the loop, or just skip one turn.

Step-by-step explanationsRunnable JavaPractice + answer

முக்கிய விளக்கங்கள் தமிழில் உள்ளன. Runnable example மற்றும் கூடுதல் practice notes ஆங்கிலத்தில் உள்ளன.

இந்தப் பாடத்தில்…

  • Explain the key idea behind Break and Continue.
  • Read and run a complete example, then predict what changes.
  • Recognize the topic-specific mistake discussed below.
01 / The concept

அடிப்படையைப் புரிந்துகொள்ளுங்கள்

break exits the nearest enclosing loop or switch. continue skips the rest of the current loop iteration and proceeds according to that loop form. Trace which lines run before and after each statement.

02 / Step by step

விரிவான விளக்கங்கள்

Java Break Statement

break statement-ஐ use பண்ணி loop-ஐ நடுவுல நிறுத்தலாம்:

Java Continue Statement

continue statement ஒரு iteration-ஐ skip பண்ணும் — loop நிற்காது, அடுத்த iteration-க்கு போகும்:

break — loop-ஐ completely stop பண்றது.
continue — current iteration-ஐ மட்டும் skip பண்றது.

Java reference fragmentJAVA
// break
for (int i = 1; i <= 9; i++) {
    if (i == 5) break;
    System.out.print(i + " ");  // 1 2 3 4
}

// continue
for (int i = 1; i <= 9; i++) {
    if (i % 2 == 0) continue;
    System.out.print(i + " ");  // 1 3 5 7 9
}

`continue` statement என்ன செய்யும்?

  1. Loop-ஐ முழுவதும் நிறுத்தும்
  2. Program-ஐ exit செய்யும்
  3. Current iteration-ஐ skip செய்து அடுத்ததற்கு போகும்
  4. Loop-ஐ restart செய்யும்
Reveal answer / விடை

Current iteration-ஐ skip செய்து அடுத்ததற்கு போகும்

`continue` current iteration-ஐ skip செய்யும் — loop முடியாது. `break` loop-ஐயே exit செய்யும். Example: even numbers மட்டும் print செய்ய odd numbers-ஐ `continue` செய்யலாம்.

03 / Read and predict

முழுமையான உதாரணம்

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.

Main.java · complete runnable exampleJAVA
public class Main {
    public static void main(String[] args) throws Exception {
        for (int n = 1; n <= 6; n++) {
            if (n == 2) continue;
            if (n == 5) break;
            System.out.println(n);
        }
    }
}
Predict first. Then reveal the expected output / வெளியீடு
1
3
4

The output shown was checked by running this complete example. Trace the executed statements in order, then compare with your run.

04 / Learn by changing

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.

Open Java editor ↗
After the editor loads, choose Load this lesson example, then press RUN.

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.

05 / Your turn

நீங்களே முயற்சி செய்யுங்கள்

Practice challenge

Move the println before both if statements. What changes?

Reveal the answer and reasoning / விடை

The values 1 through 5 are printed: each value is printed before the skip or exit decision.

தவிர்க்க வேண்டிய தவறு: continue does not terminate the loop. In a while loop, make sure it cannot skip the update needed to finish.

பாடத்தின் சுருக்கம்

  • 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.

Coding Tamilan · Understand the idea. Try the code. Build the habit.