Lecture 10, CS 302-7 and 8, February 13
i. Due February 24
i. De Morgan’s Law
i. This will help avoid scope issues
i. Be careful with <=, < etc in conditions
i. Count-controlled vs event controlled
ii. Definite vs indefinite
for(<initialization>;<condition>;<update>)
{
//body
}
i. Three expressions: initialization, condition, update
ii. Body is executed between the condition and update
iii. The variable that we initialize in the <initialization> step is only declared within the for loop
1. So, we can’t do:
for(int a=0;a<10;a++) {
//Do something
}
S.o.p(a);
i. Can count down, count up by 2, etc
ii. Note – if we define counter before initialize, we can use it afterwards
i. string.toUpperCase()
ii. string.substring(start, end)
iii. string.charAt(index)
iv. string.length()