betweenGo

Effective Java Collections

by Frank Kim on Sep.01, 2008, under Java SE

I thought this article, Effective Java Collections, was excellent.  Here is the summary of the article.

  1. Use the isEmpty() method of the collection.
  2. Avoid returning null to mean an empty collection.
  3. Create an empty collection using Collections.empty***() methods.
  4. Iterate through collections using the foreach form when possible.
  5. Use the proper collection, Collection, Map, Set, List.
  6. The left side is always an interface!  (So is the return type of methods.)
  7. If you’re explicitly casting, chances are something is wrong. Use generics.


  • Share/Bookmark

Related posts:

  1. Java Method with Generic Return Type
  2. Covariant Return Types in Java
  3. Static Import
  4. Java allocation is no longer expensive
  5. Linked List Interview Questions

:

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!