Home | Search | Browse | New Titles | Stockists | Features | Competitions
 

 

The release of Java 2 Platform Standard Edition 5 (J2SE 5) is the beginning of the second Java revolution. Strong words, but not an overstatement. Unlike the previous Java upgrades that offered important but incremental improvements, J2SE 5 fundamentally changes the language. During development, the codename for J2SE 5 was "Tiger" - a fitting name!

As most programmers know, the first Java revolution was started by the original 1.0 release. At that time, Java radically transformed the way we program for the Internet. Building on the well-known syntax of C/C++, Java streamlined the object model, simplified memory management and added built-in support for multithreading. Today we take these features for granted, but nearly a decade ago, they were fundamental and far-reaching advances.

Over the years Java continued to grow, evolve and otherwise redefine itself. Unlike many other languages that are slow to incorporate new features, Java has continually been at the forefront of computer language design. One reason for this is the culture of innovation and change that came to surround Java. As a result, Java has gone through several upgrades - some relatively small, others more significant. But none of these upgrades compare in scale, size and scope to that of J2SE 5.

Java 2 Platform Standard Edition Version 5 ranks as the most significant change to Java since its original release. Its additions are so profound that they will forever alter the way that Java code is written. J2SE 5 is a revolutionary force that cannot be ignored. To understand why this is reshaping the Java world, consider this list of J2SE 5's major new features.

• Generics
• Metadata (Annotations)
• Autoboxing/unboxing
• Enumerations
• The enhanced, "for-each" style for loop
• Variable-length arguments (varargs)
• Static import
• Formatted I/O
• Concurrency Utilities
• Upgrades to the API, including the Collections Framework

This is not a list of minor tweaks or incremental upgrades. Each item in the list represents a significant addition to the Java language. Some, such as generics, the enhanced for, and varargs, introduce new syntax elements. Others such as autoboxing and auto-unboxing, alter the semantics of the language. Metadata adds an entirely new dimension to programming. In all cases, substantial functionality has been added.

Of these additions, the one that most profoundly affects every Java programmer is generics. At its core, the term generics means parameterized types. Parameterized types are important because they enable the programmer to create generic methods, classes, and interfaces in which the type of data operated upon is specified as a parameter. As a point of reference, generics in Java are somewhat similar to templates in C++.

Generics enhance Java programming in two important ways.

1. Code Re-use
Generics expand the programmer's ability to re-use code which makes it possible, for example, to create a single class, that automatically works with different types of data. You no longer need to create a separate version of the class for each different data type.

2. Type Safety
Generics add type safety. Because the generics mechanism implicitly handles type conversions, explicit casts are not required. Thus, casting errors are avoided and the compiler can flag type-mismatch errors.

In short, generics enable the programmer to create classes, interfaces and methods that automatically work in a type-safe manner with different types of data. This is a powerful feature that improves both the reliability and the resilience of our code.

Because many of the classes, interfaces and methods in the Java API have been updated to generics, much pre-generics code is now considered obsolete. Although J2SE 5 will still compile older code, it will issue a warning when a pre-generics version of an updated class or interface is encountered. The message is clear: Java programmers must upgrade their existing code base to generics as quickly as possible. They are the future of Java programming and the future belongs to those programmers who gain mastery over this important new feature.

With the release of J2SE 5, the world of Java programming has changed. Many of the techniques that programmers have relied on in the past are now outdated, having been replaced by better, more powerful constructs. Programmers who fail to adopt the new strategies will soon find themselves left behind. Frankly, in the competitive world of programming, no Java programmer can afford to be left behind.

Herbert Schildt is a leading authority on the Java, C, C++, and C# languages and is a master Windows programmer. His programming books have sold more than 3 million copies worldwide and have been translated into all major foreign languages.

To find out more, visit www.HerbSchildt.com