They have used these constants to initialize collections with immutable instances. Why they didn't simply use the Collections.EMPTY_LIST for initializing lists? Is there a benefit in using the following method?

@Ali: I don't know but not everyone is aware of every single detail of the Java APIs. The other day I answered someone and made use of Integer's numberOfLeadingZeros(..) method and some knowledgeable programmer commented that he didn't know about that method. I'm not coming to SO or to the daily WTF posting everytime I encounter some piece of code re-inventing some part of an obscure Java API and calling that "interesting". It is not interesting, not much to see here besides hair-splitting, move along.
–
SyntaxT3rr0rMay 2 '10 at 15:33

2 Answers
2

No, there is no benefit. The only difference apparent to me is that this method is guaranteed to return a different EMPTY_LIST than any List created with Collections.emptyList(), whereas implemenations of Collections.emptyList() may or may not return the same List instances. I am more inclined to agree with @WizardOfOdds's comment that they simply didn't know about those API functions.

The may be times when it improves performance by reducing the number of implementations used at a particular call-site, allowing better monomorphic and bimorphic inlining optimisations. Bit of a long shot, though.