Are there any major disadvantages of initializing a Java collection, e.g. ArrayList at the time of declaration such as :
List<String> strList = new ArrayList<String>();
The main purpose is to avoid the clutter of null checks while retrieving the elements.
Thanks
In general, the only disadvantage is that you may end up with a whole bunch of collections doing nothing and have unnecessarily done work to create the collection.
My personal preference is to assign a valid collection always unless there's a definite reason to avoid the memory and initialization overhead, such as within loops and other possible performance considerations. And if I was always ensuring the objects were initialized to non-null I would not then do redundant null-checks before using the collections.
The caution I would add is to make sure if you do use the collection that you use it and don't, in later code, replace it with an entirely new collection (that would indicate a probable design flaw). To enforce this you can declare the collection as final.