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
nullto mean an empty collection.
- Create an empty collection using
- 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.