java - Making new objects of different classes in a single for loop -


i'm new programming, , stuck. have 5 different classes in project: foo1, foo2, foo3, foo4, , foo5 different, similar things. need create new object of each one, like: foo1 bar1 = new foo1(); foo2 bar2 = new foo2(); foo3 bar3 = new foo3(); , on. sure works, i'm trying find way conserve lot of space if instantiate objects need in single for-loop, or in least put objects want create in single array work out of. can working if same class, not if different. possible?

try read polymorphism can use in java. how interfaces , abstract classes works. extends , implements keyword in java , other ...

i found these tutorials looks good:

tutorialspoint polymorphism

oracle polymorphism


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -