I want to make API calls to a bunch of different API services. I have an abstract class called ApiService
that contains common methods for each subclass. Every new API will have to inherit and implement these methods.
My question is: how can I go through all the subclasses of ApiService
and call their methods?
Right now, I have a static array of all the services instantiated already (which means that new services must be manually added to the array) that looks something like this:
ApiService[] services = {new SubService1(), new SubService2(), ...};
I was wondering if there was a better way of doing this.