Further to a previous post I'm hope someone can help clarify/confirm my understanding of the following java generics statements, and offer some input as to what the final one means:
If:
Class<abc> className = x
means to assign x
of type abc
to Class
variable className
And:
Class<? extends IAbc> className = x
means to assigns x
which implements interface IAbc
to Class
variable className
What does:
Class<? extends IAbc<?>> className = x
mean?
That just means that IAbc
is itself a generic type IAbc<T>
, you're asking for a Class
object representing some implementation of some parameterization of IAbc
but you don't know (or care?) which.
More interesting would be something like
Class<? extends IAbc<? extends Number>>
which would accept any class that implements IAbc<Number>
, IAbc<Integer>
, IAbc<Double>
, etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.