java - Declare and iterate through ArrayList of classes that extend a class -


i may going wrong way, possible iterate through collection of classes extend specific class? i'm thinking of declaring :

arraylist<? extends interfacecomponent> components = new arraylist<? extends interfacecomponent>(); 

but throws error. possible?

edit : , iterate though :

    (<? extends interfacecomponent> t : components)     {         t.callsomemethod();     } 

right?

try this:

arraylist<interfacecomponent> components = new arraylist<interfacecomponent>();

and on list can have object implements interfacecomponent.

edit: iterate this:

for (interfacecomponent t : components) { }


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -