Sometimes while writing any program, we need to make some conditions because a program consists of a set of statements and we need to test any certain condition. For example, suppose a case when we want to compare two numbers that which number is greater and which number is smaller.
In this post, we will talk about the decision making statements which we generally used in our program to test certain condition or conditions.
Decision Making Statements
Decision-making statements are the statements in Java which are used to test the various conditions in our program.
In simple words, testing condition means to check whether the given condition is true or false. If the condition becomes true then our next statement execute otherwise it will not.
There are basically 3 methods available in Java to test the conditions,
- If statement
- Switch Statement
- Conditional Operator Statement
-> If…else statement
-> Nested if…else statement
-> If…else ladder statement
-> Simple Switch Statement
Conditional Operator Statement
-> Conditional Statement