Java – what are the benefits of extending generics by specifying new types as the actual types of generics

I saw this pattern somewhere: @ h_ 403_ 2@class A extends B { }

This structure is somewhat unusual for extending generics by specifying the new type as the actual type of generics What's the usage? Does this model have a name? Is there an alternative model?

Example: https://code.google.com/p/selenium/wiki/LoadableComponent

Jump to: public class editissue extends loadablecomponent < editissue >{

Editor: after reading the reply, I seem to need to change the compiler's understanding of type checking In my mind, my beef has this pattern. If two as need to be the same, is there any way not to repeat them? But there seems to be no better way to propagate the type of derived class to the parent class

Solution

Of course, the answer to OOP is that a is B. If a is not B but not a, it should only use B to form B to take advantage of B's function

Presumably, B also has some generic implementations that take advantage of restrictions on generic types

Another use case is that B looks like:

Now, subclasses can implement createcopy, and client code can use it safely without conversion

Compare the above:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>