I have a function eventIterable() in six different classes, each with different names. These classes are being stored in an Object[].
I have a custom ArrayList class (I had to create my own – long story, don’t bother suggesting I use the standard one), and within it, you can access indexes from the ArrayList.
Each of these class objects are stored at an index in the array list. However, since the type of the array is Object, I can’t call the functions. I can’t change from Object to a specific class because each of the classes is unique. They all share the eventIterable() function, however.
The goal is to be able to iterate through all of the classes in the ArrayList, and run the eventIterable() function within each class.
You should create an interface containing the
eventIterable()method, and make all of the classes implement that interface.You can then use a list of that interface rather than a list of objects.