Type the Controller event loop (polymorphic dispatch)
Type the Controller event loop (polymorphic dispatch)
Answer
for (Event e : new ArrayList<Event>(eventList)) if (e.ready()) { e.action(); eventList.remove(e); }
The framework never names a concrete event. e.action() dispatches polymorphically to the inner class's override; the copied list lets action() safely modify eventList.