java - Basic generic methods and how to call a method from non-generic class? -
I really need help with generic methods and generic
Here I'm imagining:
In the MyPets class, in the above, add a method that takes T as the parameter. This method is called myGenericMethod, it will call for Manoj. Call the menoise method for both of your pets inside this method.
The question is how do I call the menyois method from the animal class (non-general category). Do I have to use Reflection?
Public category MyPets & lt; T & gt; {// T is creating myGenericMethod as its parameter in the form of its parameter Public Zero myGenericMethod (TT) {// How do I call Mena Niez () from the Animal Class? }} thanks
to extend animals to you Your usual type of announcement is required:
public class mappings & lt; Tee Extend Animals & gt; {Public Zero myGenericMethod (tt) {t.makeNoise (); }}
Comments
Post a Comment