Most useful overlooked Java APIs
Friday January 5, 2007 by Derek Young
It’s easy to get stuck programming with the APIs you’ve been comfortable with since the old days. Reading over other people’s code and reviewing the API changes after each Java release can help break that habit.
Some classes and functions that seem to be overlooked frequently, in no particular order:
- StringBuilder – everyone knows StringBuffer but you don’t see a lot of use of StringBuilder. It’s unsynchronized and therefore faster than StringBuffer. You almost never need a synchronized StringBuffer so it’s a clear winner.
- Arrays.asList – nice varargs helper to create lists of the right type. asList(1, 2, 3).
- Collections.emptyList /emptySet/emptyMap – easy, efficient way of returning an empty read only collection.
- String.split) – I still see a lot of the old school StringTokenizer even though split is much easier to use.
- Set – I’m surprised by how much code there is where HashMap or HashTable is used like a set, with the value set to the key.
- String.CASE_INSENSITIVE_ORDER instead of converting your strings to lowercase everywhere, just construct your collection with CASE_INSENSITIVE_ORDER. Your strings are preserved in their original case and you have all the benefits you get by converting everything to lowercase.

What I would do with the open-sourced JVM Linux RAID: lessons learned
