Today I will share with you some tips and tricks for writing better Java code.
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:
- Declare a variable for a temporary collection
- Create a new empty collection and store a reference to it in the variable
- Put things into the collection
- Pass the collection to the method