Lecture 8, CS 302-6, September 21
i. Tree structure
i. Substring of end, beg index, eg substring(3,1)
ii. Ifs without elses are ok
1. We’ll show an example of this eventually
i. Example – Birthday.java
i. (actually, in Java 7, String is allowed as well)
switch (digit)
{
//Execute case 1 if digit==1
case 1: do something; break;
//do case 2 if digit==2
case 2 : do something else; break;
//If digit !=1 and digit !=2 do this
default: do the default behavior; break;
}
boolean bool=true;
boolean bool2=(1==1); //true
boolean bool3=false;
boolean bool4=(1+1==1); //false
i. if(bool)…
i. && -> And
ii. || -> Or
iii. ! -> Not
i. A&&B, A ||B, !A
i. A || B && !C means A || (B && (!C))
ii. Rule of thumb: When in doubt, use ()
i. 1==2 and 3>2 can both be interpreted as booleans