Hello.
So I decided to study Generic a little deeper, because I needed to write my own class. Previously, somehow did not pay attention, but now I want to understand.
The problem is that I can't understand the essence of using <T super SomeClass> . I read a lot of literature, but still did not understand.
There is another opposite wildcard - <T extends SomeClass> . With this, everything is obvious. Powerful concept. We have a superclass, in my case SomeClass . Maybe the interface. But it does not matter. He has his own methods. Who will definitely be! It does not matter how many times was inherited and what methods added. It is important for us that we are confident that any class heir will have methods of the superclass, and we don't care what the class of the heir is called, just call the methods, that's all. It's all clear.
BUT here <T super SomeClass> something is not at all clear what the benefits are. I understand that this is the opposite thing <T extends SomeClass> , that is, just one wildcard restricts the top, the other below. It is not clear why to use it.
I read about the concept of PECS. Examples looked, but did not understand.
What is the use of this class being a superclass of SomeClass . Well, let's say Object -> ParentSomeClass -> SomeClass will have such a hierarchy. Well, all classes will be valid, and there will be no compiler error. BUT what is the use of this? I can implement any methods in ParentSomeClass and in SomeClass . Suppose there are no methods in SomeClass in SomeClass . And in Object , of course, there will be no methods implemented by ParentSomeClass . And what then is the sense, some problems.
I read that it is used when you need to add elements to the collection, for example. But still did not understand the point.
Please explain in as much detail as possible.