COP-3338, Programming III Lectures
- Aug 29: Opening remarks and Java basics
- Remarks PDF slides
- Basics PDF slides
- Examples of C++ nonsense that can never happen in Java
(writeup by Cay Horstmann)
- In Java, if you step outside of the bounds of an array, the
VM will signal a problem. In C++, you might run for a while without a problem.
- In Java, the garbage collector will never reclaim an object while it is still usable. In C++,
you clean up yourself, and you can delete an object
while it is still usable, resulting in unpredictable behavior.
- In Java, objects are never created on the stack, so pointers
cannot go stale. Not so in C++.
- In Java, the compiler is required to perform a conservative flow analysis
to make sure that local variables are definitely assigned prior to use of their
Not so in C++,
which can get you into oodles of trouble, especially when pointers
- Java is very type safe. C++ is not.
- A host of C++ pitfalls
just do not happen in Java (one does have a corresponding Java pitfall though).
- Aug 31: Classes
- Sep 5 and 7: Inheritance, Exceptions, and Interfaces
- Sep 12 and 14: The Object class, Reflection, and the Proxy Pattern
- Object class PDF slides
- Reflection PDF slides
- Illustration of the correct way to override
equals, hashcode, toString,
- Illustration of using reflection to invoke main
- Using accessible fields to get private data
- Illustration of the proxy pattern.
Shows generation by hand, generation by using Java 1.3 dynamic proxies,
and an approximation of what
the dynamic proxy is actually producing for you behind the scenes
- Sep 19: I/O and the Decorator Pattern
- PDF slides
- Program to copy from one file to another, with line numbering
- Program that uses StringTokenizer to parse a line of input into two ints
- Program that uses File class to get information about a directory and its contents
- Sep 21: The Collections API and the Iterator Pattern
- Sep 26 and 28: Inner Classes
- PDF slides (revised 9/26/00 9PM)
- SortedArrayList class illustrates the use of
instance inner classes for iterators
and nested classes too
- A nonsense demo that illustrates how to construct
inner objects from outside the outer class,
name clashes with locals, inners, and outers, and also
shows how the compiler generates wrappers to access private
outer class members.
- Series of programs that show the moving of a function
object closer and closer to its use.
from interfaces lecture.
- Oct 3 or 10, 12 and 17: Threads and Synchronization
- Because of the weather, part I is Oct 3 3:30PM OR Oct 10 5:00PM.
- PDF slides
- Illustrates basics of getting threads to run:
- Illustrates threads corrupting data:
- Series of examples using an Account.
Some threads do deposits, some do withdraws on shared account.
- Two examples with multiple monitors
- Static methods have different monitors than instance methods:
- Oct 19: Networking
- Oct 24 and Oct 26: Server-side Programming
- Oct 31 and November 2: Swing and Applets
- Nov 7 and (a little of) 9: Serialization
- Nov 14, and 16: Programming in C
- Nov 21: Native Methods in C and C++
- PDF slides
- Hello World:
- Visual C++ setup
cl -GX /GR -IC:\jdk1.3\include -IC:\jdk1.3\include\win32 HelloNative.cpp -LD -FeHelloNative.dll
- Accessing fields of Date class:
- Accessing methods of Date class:
- Accessing strings in Date class:
- Using arrays:
- Using exceptions:
- Creating a Java VM from C++:
- Nov 28: JDBC
- PDF slides
- This class will be held on the same day as evals, since there is not much material
- Nov 30: Java 1.2 Security Basics: Permissions and Policy Files, Code Signing
- Another whiteboard lecture, with a few examples.
- Dec 5: Introduction to RMI
- Dec 7: Class will not be held