CodeToConcept
About

java

java Tutorials

Introduction
Java Variables
Java Data Types
Java Type Casting
Java Operators
Java Input/Output
Java Class & Object
java Method
Java Constructor
Java this keyword
Java super keyword
Java Method Overloading and Overriding
Java Interface
Java Abstract Class
Java Memory Management
Design Patterns
JDBC (Database Connectivity)
Java IDEs

java Tutorials

Introduction
Java Variables
Java Data Types
Java Type Casting
Java Operators
Java Input/Output
Java Class & Object
java Method
Java Constructor
Java this keyword
Java super keyword
Java Method Overloading and Overriding
Java Interface
Java Abstract Class
Java Memory Management
Design Patterns
JDBC (Database Connectivity)
Java IDEs

Sample Question

Think it through, then check the tutorial.

CodeToConcept

Quickly learn through simple, structured, and practical coding tutorials. Build your confidence from step zero to real-world experience.

© 2026 CodeToConcept. All rights reserved.

Quick Links

AboutTutorials

Tutorials

JavaHTMLCSS

Support

Privacy PolicyTerms of ServiceContact
GitHubTwitterYouTube

Control Statements in Java

Control statements decide which instructions run, how often they run, and when a loop should stop or skip a step. Without them, a simple program would mainly follow its statements from top to bottom.

Why Do We Need This?

A shop may give a discount only when a bill reaches a certain amount. A program may also need to print every item on that bill. The condition chooses an action, and the loop repeats an action.

Main Ideas

ConceptWhat it means
if and if-elseChoose actions using a condition
switchChoose between cases for a value
for, while, and do-whileRepeat a block of code
breakExit a loop or switch
continueSkip to the next loop iteration

Simple Working Example

Run this program on its own. All required imports and classes are included.

public class HelloWorld {
    public static void main(String[] args) {
        for (int lesson = 1; lesson <= 3; lesson++) {
            if (lesson == 2) {
                System.out.println("Lesson 2 needs revision");
            } else {
                System.out.println("Lesson " + lesson + " completed");
            }
        }
    }
}

Output

Lesson 1 completed
Lesson 2 needs revision
Lesson 3 completed

The for loop runs three times. On each turn, the if condition checks the lesson number and chooses which message to print.

Topics in This Section

  • Java if, if-else
  • Java do-while and for loop
  • Java break, continue

Easy Way to Remember

Use a condition to choose, a loop to repeat, and a jump statement to change the flow inside a loop or switch.

See you in next page....??

← Java Input/OutputJava if, if-else →
← Java Input/OutputJava if, if-else →