Object Oriented Software Engineering   View all facts   Glossary   Help
subject > programming language construct > statement > decision-making statement > Java decision-making statement
Updecision-making statement, Java statement

Java decision-making statement comparison table
Subject omit avoid by have example has part have form
Java if statementcurly brackets:
if(condition)
doSomething();
else
doSomethingElse();
if it contains only a single statement
  else block
if(condition)
{
// statements to execute if condition is true
}
else
{
// statements to execute if condition is false
}
Java switch statement using polymorphism  
switch(primitiveVariable)
{
case value1:
// statements to execute if variable equals value1
break;
case value2:
// statements to execute if variable equals value2
break;
...
default:
// statements to execute if none of the above is true
break;
}
Java try catch statement  
//Any division by zero that occurs when executing the 
//try block will result in execution of the catch block.
//Once either block completes, execution continues
//at the statement after the catch block.
try
{
result = numerator / denominator;
validResult = true;
}
catch (ArithmeticException e)
{
validResult = false;
}
  

Updecision-making statement, Java statement