Daily Archive for January 5th, 2009

Java Tips: More About Initializing Collection

Some time ago I wrote an article about initializing collection in Java. I just found that Java actually provides several methods to help this task if you just want to create empty or singleton collection.

Look at this:

Collections.EMPTY_LIST
Collections.EMPTY_MAP
Collections.EMPTY_SET
Collections.singleton(...)
Collections.singletonList(...)
Collections.singletonMap(..., ...)