• Home
  • Jobs
  • Courses
  • Certifications
  • Companies
  • Online IDE
  • Login
  • Signup
MYTAT
  • Home
  • Jobs
  • Courses
  • Certifications
  • Companies
  • Online IDE
  • Login
  • Signup
Java
  • Java Introduction
  • Java Getting Started
  • Java Syntax
  • Java Comments
  • Java Variables
  • Java Data Types
  • Java Type Casting
  • Java Operators
  • Java Strings
  • Java Math
  • Java Booleans
  • Java If ... Else
  • Java Switch
  • Java While Loop
  • Java For Loop
  • Java Break And Continue
  • Java Arrays
  • Java Methods
  • Java Method Parameters
  • Java Method Overloading
  • Java Scope
  • Java Recursion
  • Java OOP
  • Java Classes And Objects
  • Java Class Attributes
  • Java Class Methods
  • Java Constructors
  • Java Modifiers
  • Java Encapsulation
  • Java Packages
  • Java Inheritance
  • Java Polymorphism
  • Java Inner Classes
  • Java Abstraction
  • Java Interface
  • Java Enums
  • Java User Input (Scanner)
  • Java Date And Time
  • Java ArrayList
  • Java LinkedList
  • Java HashMap
  • Java HashSet
  • Java Iterator
  • Java Wrapper Classes
  • Java Exceptions - Try...Catch
  • Java Regular Expressions
  • Java Threads
  • Java Lambda Expressions
  • Java Files
  • Java Create And Write To Files
  • Java Read Files
  • Java Delete Files
  • Home
  • Courses
  • Java
  • Java Break And Continue

Java Break and Continue

Previous Next

Java Break

You have already seen the break statement used in an earlier chapter of this tutorial. It was used to "jump out" of a switch statement.

The break statement can also be used to jump out of a loop.

This example stops the loop when i is equal to 4:

Try it now

Example

for (int i = 0; i < 10; i++) {
  if (i == 4) {
    break;
  }
  System.out.println(i);
}



Practice Excercise Practice now

Java Continue

The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.

This example skips the value of 4:

Try it now

Example

for (int i = 0; i < 10; i++) {
  if (i == 4) {
    continue;
  }
  System.out.println(i);
}



Practice Excercise Practice now

Break And Continue In While Loop

You can also use break and continue in while loops:

Try it now

Break Example

int i = 0;
while (i < 10) {
  System.out.println(i);
  i++;
  if (i == 4) {
    break;
  }
}
 

Continue Example

Try it now

 
int i = 0;
while (i < 10) {
  if (i == 4) {
    i++;
    continue;
  }
  System.out.println(i);
  i++;
}



Practice Excercise Practice now

Previous Next
COMPANY
  • About us
  • Careers
  • Contact Us
  • In Press
  • People
  • Companies List
Products
  • Features
  • Coding Assessments
  • Psychometric Assessment
  • Aptitude Assessments
  • Tech/Functional Assessments
  • Video Assessment
  • Fluency Assessment
  • Campus
 
  • Learning
  • Campus Recruitment
  • Lateral Recruitment
  • Enterprise
  • Education
  • K 12
  • Government
OTHERS
  • Blog
  • Terms of Services
  • Privacy Policy
  • Refund Policy
  • Mart Category
Partner
  • Partner Login
  • Partner Signup

Copyright © RVR Innovations LLP 2025 | All rights reserved - Mytat.co is the venture of RVR Innovations LLP