JavaFundamentals7_L1.pdf

(554 KB) Pobierz
Java Fundamentals for Android Development
Lesson 1
Java Overview
Control Flow
Control Flow
Decision-making statements
if-then
if-then-else
Switch
Looping statements
for
While
do-while
Branching statements
break
continue
return
Control Flow
The If-then Statement
It tells your program to execute a certain section of code
only if a particular test evaluates to true.
void stopCar() {
// the "if" clause: car must be stopped
if (isMoving) {
// the "then" clause must stop car
isMoving = false;
}
}
Control Flow
The If-then Statement
The opening and closing braces are optional, provided
that the "then" clause contains only one statement:
void stopCar() {
// same as above, but without braces
if (isMoving)
isMoving = false;
}
Zgłoś jeśli naruszono regulamin