|
|
|
Examples of the material from the lectures will be posted here.
- 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
- A class that shifts each
character in a string to the next character in the unicode sequence.
- Recursively reversing a string
- Recursive powers 1, Recursive powers 2
- Experimenting with arrays
- See text for implementation of linear and binary search.
- Experimenting with
ArrayList
- Simple class for a student, Testing Student class
- String Formatting
- References
- Representing student records 2: Student, Course, StudentTest
- Parameters and References
- Some miscellaneous examples:
Alphabetize.java,
CommandLineTest.java,
DoubleArrayList.java,
Lab5.java,
PowerPrint.java,
QuickTest.java,
QuickTestObject.java
- 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
-
NegativeInputException,
PositiveInteger,
PositiveIntegerTest
-
DividingMachine,
DividingTest
- 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
|
|