Java News from Thursday, December 31, 2009

Google has released version the Google Collections Library 1.0, which extends the standard JDK collections classes with:

I've been using this library for a couple of years now. There's some good stuff in here, but it's mostly relatively minor. For example instead of writing

List<String> list = new ArrayList<String>();

you can instead write

List<String> list = Lists.newArrayList();

Yes, it saves a few characters and avoids an annoying redundant generic type declaration; but is it worth the extra dependency? The downside of this sort of library is that most projects don't need but a small subset of this functionality, and end up pulling in a lot of extra stuff they don't need to get the one or two pieces they do need. Of course it's open source (Apache License 2.0) so you can just fork out the one or two pieces you need for your own program and repackage them; but I do wish Java had a better way to use just a Multimap, for example, without pulling in Multiset, Bimap, forwarding collections, and everything else. Java 5 or later is required.