Lecture 7, CS 302-6, September 19
i. theString.length()
i.
http://download.oracle.com/javase/6/docs/api/
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And by opposing end them?
->If I am then:
Suffer the slings and…
Else:
Take arms…
if (condition)
{
do this;
}
else
{
do that;
}
i. {}
1. Not necessary if there is only one line after, but good form
ii. There is no semicolon after if/else
i. Indentation is not an accident – it helps us keep track of which parts of our programs go together
i. If(){do this1; do this2;} else {do that; do this2;} - > move do this2; below
i. Note difference between = and ==
1. = assigns, == tests equality
ii. != means not equal to
i. If day==Monday then if time is in 11:00-11:50, you are in CS. If time==12-1, I have office hours. Otherwise, if the day==Tuesday…
if(a==b)
{
if(a==2)
{
~
}
else
{
~
}
}
else if(a>b)
{
~
}
else
{
~
}