1

What benefit gives us the second signature method with wildcard <?>?

public static <T> void firstCheckList(List<T> myList, T obj)                
public static <T> void secondCheckList(List<?> myList, T obj)
barbara
  • 3,111
  • 6
  • 30
  • 58

1 Answers1

1

The benefit is that in the 2nd option the list members don't need to be the same type as obj

If there is a correlation between myList and obj (type-wise) it is best to use the 1st option, if there isn't use the 2nd option