Loops Flashcards
Write the While Loop Structure
while(somecondition){
//repeat code in the squiggly brackets if the condition is true
}
As long as the condition is true in the ( ) of loop conditions, the code in the { } will repeat ______
indefinetly
What conditions can be placed in the ( ) of while loops?
same conditions used in if statements
What will this code do:
int intNumber;
intNumber = 3
while (intNumber <= 5){
con.println(“Wahoo”);
}
print “Wahoo” indefinetly
What will this code do:
intNumber = 5;
while (intNumber <= 5){
con.println(“Wahoo”);
}
print Wahoo indefinetly
What will this code do:
intNumber = 10;
for (intNumber <= 5){
con.println(“Wahoo”);
}
print nothing
Function of the Looping Structures
repeat whatever is in the { } as long as the condition is true
repeat whatever is in the { } as long as the condition is true
Function of the Looping Structures
When do loops (while/for) stop repeating?
Once condition inside ( ) is false
Function of Inatializing Variables
to give variables default values
number variables are usually initialized to ______
0
string variables are usually intialized to _____
empty double quotes (i.e. “”)
to give variables default values
Function of Initializing Variables
Write the code to check if a string does NOT include certain characters
!strVariable.equalsIgnoreCase(“xxx”)
Function of:
!strVariable.equalsIgnoreCase(“xxx”)
checks if a string does NOT include certain characters