It is little strange that no one really uses emptyList like he should in Java. So this is small post showing how to use the emptyList method in the Collections class. Question: How to create an empty list ? lets assume that we have a class Book with multiple titles. So the class in our examples will be: import java.util.List; public class Book { private List<String> titles ; public void setTitles(List<String> titles) { this . titles = titles; } public List<String> getTitles() { return titles ; } } Lets say that in our snippet we have something like : Book myCrazyBook= new ...
Blog about the light side of the *.java