See also the lecture notes and assigned readings.
From Lectures
These are examples from lectures in summer 2005.
- Hello world
- Type conversions
- Lazy boolean operators
- Control structure examples:
if
statement,while
statement,do/while
statement,for
statement - User input with
Scanner
- Creating a function
- A class with methods to solve quadratic equations, test code for
Quadratic
- Using class library code: not imported, imported class
- Recursively reversing a string
- Recursive powers 1, Recursive powers 2
- Experimenting with arrays
- See text for implementation of linear and binary search.
- Simple class for a student, Testing Student class
- Experimenting with
ArrayList
- String Formatting
- References
- Representing student records 2: Student, Course, StudentTest
- Parameters and References
- Pairs (and interfaces): Pair1: old interface (any
Object
), Pair2: interface with type parameter, PairTest. - Inheritance example: parent class (
A
), child class (B
),A
/B
test code. - Shapes inheritance:
Shape
class,Rectangle
class,Circle
class stub, shapes test code. - Files from the coffee example
- Examples of various exceptions
- Dealing with a checked exception, example minimal checked exception
- Text file outout: unbuffered output, buffered output, printing output
- Text file input:
read first line from file,
read file in chunks,
read file in chunks with
BufferedReader
, sample text file - Reading integers: read and sum integers in a file, read and sum integers with error checking, file with integers, file with integers and bad values
- Scanning tokens and regular expressions: delimiting with a literal string, delimiting with a regular expression, sample file, word input 1: with a exception, word input 2: compiled regex
- Example: Parsing an email message: email parsing attempt 1, email parsing attempt 2, sample email message 1, sample email message 2