Learn about designing correct and efficient algorithms and data structures
How to evaluate and visualize data structures and algos.
How to design large programs (in object-oriented way) so that it is easy to modify them.
Course web page: http://www.cs.williams.edu/~kim/cs136/
Distinguish int and long constants by adding "L" for long - e.g. 126L
Distinguish float and double constants by adding "f" or "F" for float - e.g., 3.1415f
Strings: "This is a string", + used for concatenation: "This is "+"a string."
Results of string + anything is string: "#"+17 is same as "#17"
Briefly review syntax of "traditional" constructs: assignment, "if", "for", "while", declarations, ==, !=, etc.
Declarations not separated from rest of code
Example: int x = 17;
x := e; => x = e;
begin ... end => {...}
if => drop "then"
while => drop "do"
repeat .. until cond => do {...} while !cond;
for i := 10 to 20 do => for (int i = 10; i <= 20; i++)
begin ... end {...}
Semicolons used as line terminator, not separator.
// starts comments which go to end of line
/* multi-line comments
are done like this */
class SillyProgram{
public static void main(String[] args){
// void as return type means this is a procedure
int sum = 0;
for (int count = 1; count <= 10; count++){
sum = sum + count;
}
if (sum > 50){
System.out.println("Sum is big: "+ sum);
// + sum converts sum to string and concatenates
} else {
System.out.println("Sum is little: "+ sum);
}
}
}
We'll see later why "class", "public", "static" are used here.Read hand-out and Chapter 3 of Core Java for more Java details.