What is the use case of a generic class whose type parameter is itself?

Viewed 104

In which situations would we use the following technique?

class A<T>
class B extends A<B> // the B appears twice

What are the benefits of such an approach?

For example, I have seen such a definition:

class HttpBase<T>

Then

class HttpRequest extends HttpBase<HttpRequest>

Also

class HttpResponse extends HttpBase<HttpResponse>
0 Answers
Related