I have a class which is supposed to work by definition only with a String parameter.
So I thought about using
class MyClass<T extends String>
But then the compiler gives a warning that string is final and I can’t extend it
Tried then with
class MyClass<String>
And got a warning because the parameter String is hiding class String.
What do I have to do?
Thanks to the enlightening comment: “do you really need generics”?
I reviewed my code and found the problem. I wanted to use a type parameter because I’m implementing an interface with one
and for some reason I thought I need the type paramter in the implementing class, like:
But that doesn’t make sense. What I needed to do is:
Solved 🙂