New Features in Java 5
- Generics – Provides compile-time type safety while still allowing a type or method to operate on objects of various types.
- Enhanced for Loop – The for statement can now be used to iterate over an array and a collection.
- Autoboxing/unboxing – Automatic conversion of primitives to wrapper types and vice versa.
- Enum type – A new enumeration type in Java.
- Varargs – Allows a method to accept a variable number of arguments.
- Static import – Eliminates the need to qualify static members with class names.
- Annotations – A special type of interface used for annotating any program elements.
Downloading and Installing Java 5
Before you can start compiling and running Java programs, you need to download and install the JDK as well as configure some system environment variables. It is also recommended that you download the API documentation.
Downloading and Installing the JDK
The JDKs for Windows, Linux, and UNIX can be downloaded from this URL:
Once you click the link, you’ll be redirected to a page that lets you select an installation for your platform: Windows, Linux, or Unix. The 64 bit versions for certain platforms are available. Also, note that the same link also provides the JRE. However, you need the JDK, and the JDK includes the JRE.
For Macintosh, download the JDK from this URL:
After obtaining the JDK, you need to install it. Installation varies from one operating system to another.
Setting the Path Environment Variable on Windows
To set the PATH environment variable on Windows NT, Windows 2000, and Windows XP, do these steps:
1. Click Start, Settings, Control Panel.