Decision Making


Decision making in programming is similar to decision making in real life. In programming we also face some situations where we want a certain block of code to be executed when some condition is fulfilled. A programming language uses control statements to control the flow of execution of program based on certain conditions.

They are used to cause the flow of execution to advance and branch based on changes to the state of a program. The list shows the Java’s selection statements.
if
if...else
nested if
if...else...if
switch...case
jump – break, continue, return

These statements allow you to control the flow of your program’s execution based upon conditions known only during runtime. It is used to decide whether a certain statement or block of statements will be executed.

Conditions and if Statements
Java supports the usual logical conditions from mathematics:
  • Less than: a < b,
  • Less than or equal to: a <= b,
  • Greater than: a > b,
  • Greater than or equal to: a >= b,
  • Equal to a == b, and
  • Not Equal to: a != b.
You can use these conditions to perform different actions for different decisions. Java has the following conditional statements:


      We have a genetic predisposition for diarrhea.    
      Runs in our jeans.