What is the use of the returned list <?> In the method?
Here is a good introduction to Java Generics. [A] and [B] explain the difference between? and object. Primarily,? indicates that the type is unknown, which is a problem if you need to add items to the list. However, if you are only reading from a list, it is normal to treat the result as an object. Although, I suggest using something like
public interface CacheClient { List<? extends Key> getKeysWithExpiryCheck(); } [A] http://java.sun.com/docs/books/tutorial/extra/generics/subtype.html
[B] http://java.sun.com/docs/books/tutorial/extra/generics/wildcards.html
If you declare your method as
List<Object> getKeysWithExpiryCheck(); You can only return List<Object> instances from it, and nothing more. If you, for example, try to return List<String> , you will get a compilation error. This is because although Object is a supertype of String , List<Object> not a supertype of List<String> .