J2SE 1.5 released

Today Sun Microsystems released the new version of Java2. Ok, in the title here is written 1.5 but you'll also often find the name JDK 5.0. I'm not sure why they made this big version-jump but tbh I also don't really care ;-)


Sun extended Java with some really nice things like (my personal favorite after looking at the changelog for about 5 minutes) a foreach loop functionality.

// Returns the sum of the elements of a

int sum(int[] a) {

    int result = 0;

    for (int i : a)

        result += i;

    return result;

}
As you can see in this example (taken right from the changelog) you can now do things like for(int i : a){...} for iterating through an array. Same works for collections :-)

Java now also offers an implicit way to pass a variable number of arguments to a function/method without having to explicitly box them into a list or array or something like that. This can be achived with a declaration like this:

public void doSth(Object... arg){...}
The three dots indicate that there is more behind it than just a simple single argument, but I haven't looked into this in detail yet :-) I just think it's nice to have it in Java.

For more details please read the release notes and or download the new J2SE from java.sun.com

comments powered by Disqus