I’ve a read only method that should be able to take either
1. Map<Date, List<X>>
or
2. Map<Date, List<Y>>
as a parameter.
Here, I’ve the following two options to define the method.
A. private <T> List<Date> myMethod(Map<Date, List<T>> map)
B. private List<Date> myMethod(Map<Date, List<?>> map)
Both work fine for me, which one is preferable?
Thanks.
The first one gives you access to the
Ttype in case you need that (for example, if you need to cast something to typeTor something like that). With the latter, you simply state that you don’t give a damn what sort of elements thatListcontains.