My problem is: I created an Arraylist serviceList
Both service1 and service2 are 2 seperate objects from 2 classes but they have the same "execute" method:
public Service1 service1;
public Service2 service2;
/*Then I add element to Arraylist:*/
serviceList.add(0, service1);
serviceList.add(1, service2);
/*then how can I run "excute" method of service1 and service2?
something like this:*/
for(Object service: serviceList){
service.execute();
}
I tried with ArrayList< Class> but it was a deadend. Thanks for your answer :D