Java method for parameters with multiple inheritance

I don’t know why I can’t find this answer online.

I have a class that implements multiple methods, and I want to write methods to expect them .I don’t know how to do it, or it’s even possible.

For example:

public void yellAtPet( arg) {
arg.yellAt("Don't go there!");
arg.pet("Good Boy");
}

This should work as a generic method without making the entire class generic:

public  void yellAtPet(T arg) {
arg.yellAt("Don't go there!");
arg.pet("Good Boy");
}

I don’t know why I can’t find this answer online.

I have a class that implements multiple methods, I want to write methods to expect them. I don’t know how to do it, or maybe even possible.

For example:

public void yellAtPet( arg) {
arg.yellAt("Don't go there!");
arg.pet("Good Boy");
}

This should work as a generic method without making the entire class generic:

public  void yellAtPet(T arg) {
arg.yellAt("Don't go there!");
arg.pet("Good Boy");}

Leave a Comment

Your email address will not be published.