Java 1.5 Examples

New Feature Description Suggested Course Example Code Potential Pedagogical Pitfalls
Scanner class. At last! Java has the facilities to teach simple input, without having to teach exceptions. CS1 html java
Printf A C-style printf method for PrintStream CS1 or CS2 html java The println method will probably remain as the first output method students should learn.
Autboxing/Unboxing Let the compiler handle wrapping and unwrapping of primitives. CS1 html java Blurs the distinction between primitives and objects, which of course are handled differently.
For each loop A new for loop for easily iterating through arrays and collections. CS1 html java Proliferation of this structure may discourage students from becoming proficient with for loops. It is a nice clean approach to iteration, but it might make things too easy.
Enumerated type. Compile-time support for type-safe enumerations. Advanced usage includes creating methods and auxiliary data. CS1 Basic
CS2 Advanced
Basic: html java
Advanced: html java
Use of Generic Collections Collections can have types checked at compile time. CS1 html java
Creation of Generic classes Creating generic type-safe classes. This is NOT a C++ template. It can be compiled and a class file is generated which removes code-bloat problems of C++. Data Structures html java The devil is in the details.

Slides from the discussion session at the CSREA multi-conference in Las Vegas. [PowerPoint] [html] [StarOffice]


Clif Presser<cpresser@gettysburg.edu>
Last modified: Tue Jun 29 09:37:51 2004