Lecture 10, CS 302-6, September 26
i. De Morgan’s Law
ii. String comparisons
i. Apple - one infinite loop
ii.
XKCD –
http://xkcd.com/140/
i. Be careful with <=, < etc in conditions
i. Count-controlled vs event controlled
ii. Definite vs indefinite
For(int i=0;i<x;i++)
{
body
}
i. For( initialization; condition; update)
ii. i is only declared within the for loop
1. So, if you try to use it after the for loop is over, java will crash
i. Can count down, count up by 2, etc. i--, i+=2, etc.
ii. Note – if we define counter before initialize, we can use it afterwards
i. Doesn’t check condition before first iteration
ii. Post-test instead of pre-test
do
{
}
while(condition);