Friday, November 23, 2007

Introduction to Java 5

From where I left off with Java, I only got through the 1.4 Exam Versions. Over 2 years of not coding in Java, what have changed so far? Java 5 was just starting back in 2005 and I've only caught a glimpse of what the technology's all about. Although it is still backward compatible, what are the features added to the Java 5 technology?

Here's what's new with Java 5:

1. Autoboxing -
Yes, as copied from C#!
2. Var-args -

Similar to javascript and Coldfusion, you can pass variable-length parameters!
3. printf Method -

Another one from C! Personally I like C#'s String.format('{0}'); better than %..?
4. Scanners

I suddenly remember Sir pchan's version of the Java Scanner in ObjectP, we had to explicitly add the class for our scanf's.. especially since we were used to C back then :D Good that they finally added it in their primitives.
5. Static imports

.. somehow I can't see an instance where I can actually use that.. hehe
6. Enumerated Types

I'll get back at you when I actually use this feature ^^
7. Generics

This we actually use in the new project. I kind of feel sad about this new feature, I would imagine less type cast exceptions that I can debug to say that I have done something for the day if ever I get into support.. hehehe!
8. Annotations
Annotations are available with the JDK version 1.5. Java annotations can be added to program elements such as classes, methods, fields, parameters, local variables, and packages.
Annotations take the form of an interface declaration with an @ preceding it and optionally marked with meta-annotations, as shown below:

Actually, I still can't fully understand the Annotations myself. For more information on annotations, visit: Annotations in Java
9. JVM Improvements
Now this really isn't my business.. but it's supposed to be better as:
"Class data sharing will provide a major performance boost. Essentially, most of the run time library is now mapped into memory as a memory image, as opposed to being loaded from a series of class files. Furthermore, a large portion of the runtime libraries will now be shared among multiple JVM instances -- this will help enormously when multiple Java programs are run at the same time."

Hmm.. maybe Java (or opensource Eclipse IDE) could figure out a way to support #region as well. Personally I miss Microsoft Visual Studio .NET's organized blocking of code to allow expanding and collapsing. Which reminds me, I wish I could try out IntelliJ IDEA some time..

---
References: http://www.sitepoint.com/article/introducing-java-5

No comments: