One valid use case for unbounded wildcard is to use it as a method parameter, when you only use those Vector's methods independent of type parameter, such as size()
, isEmpty()
, etc. :
something like :
void sampleMethod(Vector<?> vector) {
if (vector.isEmpty()) {
// your logic
}
}
and compiler will allow to pass any Vector
to sampleMethod
above.