I’ve read the documentation about variance and tried to come up with an example that is impossible in Java but possible in Kotlin. But in the end I was possible to solve all my Java examples with ? extends Something or ? super Something.
Is there something that is possible with Kotlins approach to variance only but not with Javas?
Why do you need this? Generics generally don’t provide anything that is not possible without them. Also, both implementations provide similar functionality. One notable difference is that Kotlin supports declaration-site variance and Java does not. Additionally, I believe Kotlin generics are stricter in some cases, but right now I don’t remember what was the case exactly.
I’m interested in the differences out of curiosity. I have an example in my mind (which I can no longer find), where something should have been possible with Kotlin generics that would be impossible with Java. But after looking around for a while I haven’t found an actual example.