Java - Nested Statements, Switch Statments, and Boolean Operators

0.0(0)
studied byStudied by 1 person
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/3

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

4 Terms

1
New cards
Nesting:
Putting one coding structure inside of another coding structure.

Ex: if (condition) {
if ( condition) {
statements;
} else {
statements;
} else {
statements;
}
2
New cards
Boolean opperators:
AND = &&
OR = ||
NOT = !

Ex: if (root == 2 || root == -2) {
statements;
}
3
New cards
If statements with multiple boolean opperators:
These need brackets:

Ex: if ( time == 6.0 || (day.equals ("Sunday") && time == 11.0)) {
4
New cards
Switch statement:
Used to have the program make a descicion. The condition for a switch statement must be an integer expression.

int dayOfWeek = 4;
Ex: switch (dayOfWeek) {
case 6:
System.out.println("Today is saturday!");
break;
case 7:
System.out.println("Today is sunday!");
break;
default:
System.out.println("Looking forward to the weekend!");
}

*default statement will print if dayOfWeek is anything other than 6 or 7*