Close Menu
  • Home
  • Java
  • JavaScript
  • Hibernate
  • Deployment
  • Spring
Facebook X (Twitter) Instagram
Developers GroundDevelopers Ground
Facebook X (Twitter) Instagram
  • Home
  • Java
  • JavaScript
  • Hibernate
  • Deployment
  • Spring
Developers GroundDevelopers Ground
Home Control Statements
Java

Control Statements

Akshay KulkarniBy Akshay KulkarniJanuary 16, 2024Updated:April 6, 2025No Comments3 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr Reddit WhatsApp Email
Share
Facebook Twitter LinkedIn Pinterest WhatsApp Email

What are control statements?

  • Java programs mainly use control statements to govern the execution flow. Every programming language supports the concept of control statements.
  • Control statements play an important role in logical programming.
  • In Java, two main categories classify control statements.
    1. Decision making
    2. Looping statements

Decision Making statements

  • Decision-making statements apply conditions or restrictions to program data; they serve as the control statements in this context.
  • It is possible to control the execution flow of a program by applying different conditions or restrictions.
  • Following statements come under decision making category
    1. if-else
    2. switch
  • if…else statement

    • It is a type of decision-making statement that can apply conditions or restrictions.
    • The ‘if ‘ statement accepts the condition as a parameter.
    • When the specified condition is met, the system will proceed to execute Java statements.
if else statement
if-else2
if-else3
  • Switch statement

    • It is one of the decision making statements.
    • The ‘switch’ statement is mainly used to compare single input with multiple options available.
    • Switch statement always checks for equality.
switch case

Looping statements in Java

  • Looping statements are mainly used to perform iterations.
  • Iteration is the process of executing same task or set of java statements again & again.
  • In other words iteration means repetitive operations.
  • Following are the looping statements present in java language.
    1. for loop
    2. enhanced for loop
    3. for each loop
    4. while loop
    5. do-while loop
    6. break & continue
  • for loop

    • for loop is one of the looping statements which can be used to perform specific number of iterations.
    • In order to use for loop we have to provide appropriate start & end point
  • while loop

    • while loop is one of the looping statements which can be used to perform unknown number of iterations.
    • In other words while loop is applicable if the developer doesn’t know the count of iterations.
    • In-case of while loop we don’t have to provide specific start point.
while loop
  • do while loop

    • do…while loop is one of the looping statements which can be used to perform unknown number of iterations.
    • do…while loop is also known as exit controlled loop.
    • It means condition will be verified after performing the iteration.

What is difference between while loop and do-while loop?

  • The difference between while loop and do-while loop is while loop is ‘entry controlled loop’ whereas do-while is ‘exit controlled loop’.
  • In case of while loop condition is false then iteration will not happen but in case of do while loop at least one iteration will happen even though condition is false.
do-while loop
  • Difference between break & continue

    • Break & continue are the control statements which can be used inside the loops or else inside decision making statements.
    • The ‘break’ statement can be used to explicitly stop the iterations whereas continue statement can be used to skip the iteration.
    • It is not possible to use break & continue inside the same block.
Total
0
Shares
Share 0
Tweet 0
Pin it 0
Share 0
Akshay Kulkarni

Related Posts

Understanding the Java String Class

April 10, 2025

Array in Java

February 19, 2024

Java Objects

January 11, 2024
Leave A Reply Cancel Reply

Featured Posts
  • 1
    Understanding the Java String Class
    • April 10, 2025
  • 2
    Array in Java
    • February 19, 2024
  • 3
    Control Statements
    • January 16, 2024
  • 4
    Java Objects
    • January 11, 2024
  • 5
    Java Constructors
    • January 2, 2024
Facebook X (Twitter) Instagram Pinterest
© 2025 Developers Ground, All rights reserved.

Type above and press Enter to search. Press Esc to cancel.