Java Decision Making - Java

What is Java Decision Making?

decision-making structures have one or extra situations to be evaluated or tested by means of this system, along with a statement or statements that are to be executed if the situation is determined to be actual, and optionally, different statements to be achieved if the condition is determined to be false.

Following is the general form of a normal decision making structure discovered in most of the programming languages –


Java programming language provides following types of decision making statements. Click the following links to check their detail.


Statement & Description


if statement

Anif statementconsists of a boolean expression followed by one or more statements.


if...else statement

Anif statementcan be followed by an optionalelse statement, which executes when the boolean expression is false.


nested if statement

You can use oneiforelse ifstatement inside anotheriforelse ifstatement(s).


switch statement

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

The ? : Operator

We have enclosed conditional operator? : in the previous section which can be used to replace if...else statements. It has the subsequent general form −

Where Exp1, Exp2, and Exp3 are expressions. Notice the use and placement of the colon.

To govern the value of the whole expression, initially exp1 is evaluated.

  • If the value of exp1 is true, then the value of Exp2 will be the value of the whole expression.
  • If the value of exp1 is false, then Exp3 is evaluated and its value becomes the value of the entire expression.

What is Next?

In the next chapter, we will debate about Number class (in the java.lang package) and its subclasses in Java Language.

We will be observing into some of the circumstances where you will use instantiations of these classes rather than the primitive data types, as well as classes such as formatting, mathematical functions that you need to know about when working with Numbers.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

Java Topics