The maze book for programmers!

Algorithms, circle mazes, hex grids, masking, weaving, braiding, 3D and 4D grids, spheres, and more!

DRM-Free Ebook

The Buckblog

assorted ramblings by Jamis Buck

Java SDK 1.5 Beta -- Tiger

6 February 2005 — 2-minute read

Sun recently released the public beta of Tiger, the codename for version 1.5 of their Java programming language. Ever since I first read about the features it will sport, I’ve been eager to try it out—Sun has put a lot of effort into removing some of the klunkiness from the language. For example, 1.5 features generics (templated classes), an enhanced for loop (allowing you to easily iterate across collections), annotations (arbitrary metadata that you can attach to methods, classes, and fields), autoboxing, and variable argument lists, just to name a few improvements.

I finally got my hands on it yesterday and I must say, I’m very impressed. Here’s a small sample program that simply creates a list and iterates through it. It demonstrates both autoboxing and the enhanced for loop:

  import java.util.ArrayList;

  public class ArrayTest
    public static void main( String[] args )
      ArrayList<Integer> list = new ArrayList<Integer>();

      list.add( 5 );
      list.add( 7 );
      list.add( 15 );
      list.add( 17 );

      for( int element : list )
        System.out.println( element );

The annotation feature is pretty slick, too; here’s an example in which I define a new annotation type (called “Author”), and attach it to a method so that it can be referenced at runtime by the program:

  import java.lang.annotation.*;
  import java.lang.reflect.Method;

  @interface Author {
    String name();
    String dept() default "OIT Engineering";

  public class AnnotationTest
    @Author( name = "Jamis Buck" )
    public static void main( String ... args ) throws NoSuchMethodException
      Method method = AnnotationTest.class.getMethod( "main", String[].class );
      Author author = method.getAnnotation( Author.class );

      System.out.println( "----------------------------" );
      System.out.println( "Author of AnnotationTest.main: " + );
      System.out.println( "             Their department: " + author.dept() );

I’m excited to spend more time playing with this—hopefully it’ll be quickly adopted and I can start using it “for real.”