Java Tips and Tricks

Today I will share with you some tips and tricks for writing better Java code.

Continue reading


Double Brace Initialization

Java does not have an easy one-line syntax to create and initialize collections (list, maps, sets, etc).
In order to create a simple initialized collection you have to:
  1. Declare a variable for a temporary collection
  2. Create a new empty collection and store a reference to it in the variable
  3. Put things into the collection
  4. Pass the collection to the method