Java 1.6 enhancements

Java 1.6 (officially called as Java SE 6) is released few days back. It includes a number of new API including Manangement API for JVM, Zipped output & input streams, etc. Along with  Deque and NavigatableSet in java.util, they have added a new class in the java.util called ServiceLoader. Sounds to be a fine addition, yet to play with it. They have quiely slipped in a new method for copying arrays:

Earlier it was:
int[] newArray = new int[newLength];

System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
now with the new API,
int[] newArray = Arrays.copyOf(a, newLength);
With copyOf and copyOfRange methods, now Arrays class is really useful when you manipulate the array sizes. It took so many years for Sun to figure out the right need for such a useful API!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: