I am reading about generic methods from OracleDocGenericMethod. I am pretty confused about the comparison when it says when to use wild-card and when to use generic methods.
Wildcard method is also generic - you could call it with some range of types.
The
syntax defines a type variable name. If a type variable has any use (e.g. in method implementation or as a constraint for other type), then it makes sense to name it, otherwise you could use ?
, as anonymous variable. So, looks like just a short-cut.
Moreover, the ?
syntax is not avoidable when you declare a field:
class NumberContainer
{
Set extends Number> numbers;
}