C OURSE NAME
FALL SEMESTER 20XX
INSTRUCTOR: DR. WENDY WRITER
[email protected]
04 September 20XX
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod
tincidunt ut laoreet dolore magna aliquam erat volutpat.
ava
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper s
Conditions and If Statements
You already know that 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
● Not Equal to:
a != b
You can use these conditions to perform different actions for different decisions.
Java has the following conditional statements:
1
● Use
ifto specify a block of code to be executed, if a specified condition is
true
● Use
elseto specify a block of code to be executed,if the same condition
is false
● Use
else ifto specify a new condition to test, ifthe first condition is
false
● Use
switchto specify many alternative blocks of codeto be executed
The if Statement
Use the
ifstatement to specify
uscipit lobortis nisl ut aliquip ex ea commodo consequat.
● At vero eos et accusam et justo duo dolores et ea rebum
○ Ut wisi enim ad minim veniam.
○ Quis nostrud exerci tation ullamcorper.
○ Suscipit lobortis nisl ut aliquip ex ea commodo consequat.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel
illum dolore eu feugiat nulla facilisis at vero eros et accumsan.
Lorem ipsum dolor
● At vero eos et accusam et justo duo dolores et ea rebum
○ Ut wisi enim ad minim veniam.
○ Quis nostrud exerci tation ullamcorper.
2