I thought this article, Effective Java Collections, was excellent. Here is the summary of the article.
- Use the isEmpty() method of the collection.
- Avoid returning
null
to mean an empty collection. - Create an empty collection using
Collections.empty***()
methods. - Iterate through collections using the foreach form when possible.
- Use the proper collection, Collection, Map, Set, List.
- The left side is always an interface! (So is the return type of methods.)
- If you’re explicitly casting, chances are something is wrong. Use generics.