Next:
Summary
Up:
All Units
Unit 05
Conditional statements
Summary
Statements in Java
Conditional statements
The
if-else
statement
Condition in an
if-else
statement
The
if
variant
Block of statements
Scope of variables defined in a block
Use of blocks in an
if-else
statement
Nested if's
Nested if's with mutually excluding conditions
Ambiguity of the
else
in
if-else
statements
Example: type of a triangle
Shortcut evaluation of a complex condition
Eliminating the conjunction operator
&&
in a complex condition
Eliminating the disjunction operator
||
in a complex condition
Conditional expression
Note on comparisons: equality between strings
Note on comparisons: lexicographic comparison between strings
Note on comparisons: equality between objects
Note on comparisons: comparison with
null
Exercise: modification of the class
BankAccount
Solution of the exercise on the class
BankAccount
A class to handle the time of the day
Solution of the exercise on the class
TimeOfDay
The
switch
statement
Example of
switch
statement
Observation on the
switch
statement
Omission of
break
(optional)
Exercises
Next:
Summary
Up:
All Units