0
Generic Class Issue
I'm using a generic class (a class A) to use the user-defined-data (it's a class B). Class B has a method that returns a String. The issue is why do I can't use that method when using it in class A? See the code: https://code.sololearn.com/cX9L5B7VS0AV/?ref=app
1 Odpowiedź
+ 4
All you know about type E is that it derives from Object. There is no getInfo() method in Object, hence you cannot call it.
You could insert an interface with a getInfo method and have B implement that interface and E extend it. But in your overall design you are going to run into a lot of trouble this way.
Since getInfo could be implemented as toString, a method available in Object, this would be the easiest fix of your problem right now, albeit a very special one.