This is in the context of creating an interface / API.
Best practices suggest using generic rather than specific types in interfaces — for example Map, rather than HashMap.
Best practices also suggest the preference for immutable types over mutable ones.
Thus, given both of these suggestions (and leaving aside problems with performance / footprint memory, third-party libraries / dependencies, and usability / functionality), the method should look like in the public interface
public List<SomeClass> someMethod(...)
or rather it is
public ImmutableList<SomeClass> someMethod(...)
source
share