I have three classes that they have a function with the same name. In another class I want to take the class as input and use that function, but I don't know how to do it. for example:
public interface Apple {
String showSpecifications(){
// some calculations
}
}
public interface Orange {
String showSpecifications(){
// some calculations
}
}
public interface Kiwi {
String showSpecifications(){
// some calculations
}
}
In my fourth class I want a function like this:
public String showObjSpec(Object fruit) {
fruit.showSpecifications();
}
The problem is I don't know how to define the showObjSpec input type to be able to accept Apple, Orange, And Kiwi objects. Currently, it is obvious that I am getting an error that says class Object does not support showSpecifications() function.