I just studied about generic programming, the List interface, and ArrayList, so I can understand the statement below.
Arra
What is
Collections? Why isn't itCollectionsorCollections?
Collections is a JDK class.
This class consists exclusively of static methods that operate on or return collections. It contains polymorphic algorithms that operate on collections, "wrappers", which return a new collection backed by a specified collection, and a few other odds and ends.
It's not generic and cannot be instantiated.
Why is
placed before the method nameemptyList?
Collections#emptyList is a generic method. Here, we are explicitly specifying a type argument, String.
(Isn't
emptyListcorrect for Generic?)()
No, in Java, generic type arguments for methods come before the method name.
What does the statement mean?
We are invoking the static emptyList method and assigning its return value to a variable of type List.