Launch your tech mastery with us—your coding journey starts now!
Course Content
Control Statements in Java
0/1
Loops in Java
0/1
Array Handling
0/1
String Handling
0/1
Wrapper Classes
0/1
Collections in Java
0/1
Packages
0/1
File Handling
0/1
Multithreading
0/1
Java Networking
0/1
Core Java

Java programming language provides following types of decision making statements. 

Sr.No.

Statement & Description

1

if statement

An if statement consists of a boolean expression followed by one or more statements.

if(condition) {

   // Statements will execute if the Boolean expression is true

}

2

if…else statement

An if statement can be followed by an optional else statement, which executes when the boolean expression is false.

if(condition) {

   // Executes when the Boolean expression is true

}else {

   // Executes when the Boolean expression is false

}

3

nested if statement

You can use one if or else if statement inside another if or else ifstatement(s).

if(condition) {

   // Executes when the Boolean expression 1 is true

   if(condition 2) {

      // Executes when the Boolean expression 2 is true

   }

}

4

if-else-if Ladder

A common programming construct that is based upon a sequence of nested ifs is the if-else if..else ladder. It looks like this:

if(condition)

statement;

else if(condition)

statement;

else if(condition)

statement;

.

.

.

else

statement;

5

switch statement

switch statement allows a variable to be tested for equality against a list of values.

switch(expression) {

   case value :

      // Statements

      break; // optional

   

   case value :

      // Statements

      break; // optional

   

   // You can have any number of case statements.

   default : // Optional

      // Statements

}