javawaveblogs-20

Wednesday, September 19, 2007

Java 5 new features

Several useful features were introduced in Java 5.

The compiler is also updated and all translate to already defined Java bytecode,
meaning that virtual machines can execute these features with no need for an update.
These features make writing Java code easier, cleaner, and faster.
Even if you choose not to take advantage of these features, familiarity with them is vital.

The new features of Java5 are listed below:

Generics: A way to make classes type-safe. this helps us in narrowing an instance
of a collection to hold a specific object type and eliminating the need to cast
objects when taking an object out of the collection.

Enhanced for loop: Less error-prone and cleaner for loop for use with iterators.

Variable arguments: For passing an arbitrary number of parameters to a method.

Boxing/unboxing: Support for automatic conversion between primitive types and their
reference types.

Type-safe enumerations: Clean syntax for defining and using enumerations, supported
at the language level.

Static import: Ability to access static members from a class without need to qualify
them with a class name.

Metadata: Coupled with new tools developed by third-party companies, saves developers the
effort of writing boilerplate code by automatically generating the code.

No comments:

diggthis