10

Is there is any actual difference between these this generic

public class SelfBounded <T extends SelfBounded<T>>{}

and this one

public class SelfBounded <T extends SelfBounded>{}  

?

If yes, then how can I observe them?

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Iza Marek
  • 251
  • 1
  • 6

2 Answers2

4

There are a lot of similar questions here already. You can read the following article

Or the following questions:

Community
  • 1
  • 1
masarov
  • 41
  • 1
  • None of those links directly addresses the difference between the standard self-bounded type `SelfBounded >` and the non-standard `SelfBounded `. In other words, is the raw typed version equivalent, or does it just look similar? – seanf Nov 30 '21 at 03:05
-3

The second one uses a raw type, which should never be used.

But actually neither of these declarations are normally useful. You should almost certainly just use

public class SelfBounded <T>
newacct
  • 119,665
  • 29
  • 163
  • 224