| For example, |
if (amountDue > 0)
System.out.println("You owe " + amountDue); |
| |
| will display the message only if the value of amountDue is greater than zero.
The logic path merges at the next statement in the program. |
| |
| The second form is often referred to as a "multiple statement if". |
| |
| For example, |
if (amountDue > 0)
{
totalDueFromAllCustomers += amountDue;
System.out.println("You owe " + amountDue);
} |
| |
| will add to the grand total and display the message only if the value of amountDue is greater than zero.
The logic path merges at the first statement after the end of the statement block. |
| |
| 3) Can lure unsuspecting programmers into some nasty errors. |
| |
| For example, |
if (amountDue > 0);
System.out.println("You owe " + amountDue); |
| |
| will display the message no matter what value amountDue has. |