This site requires JavaScript, please enable it in your browser!
Greenfoot back
Pando
Pando wrote ...

2018/12/30

My gif wont play

1
2
danpost danpost

2019/1/1

#
Pando wrote...
Is there a way to make an array of objects from DIFFERENT classes? Example. If i had multiple classes A, B, C... Z. Could i have an array that has something like << Code Omitted >>
Sure. You could have an array of Actor objects:
1
Actor[] actors = new Actor[10];
which could hold a Hero object, an Enemy object, a Wall object -- any object created from any class that extends the Actor class (multiple extensions allowed). For that matter, you could have an array with any type object:
1
Object[] objects = new Object[10];
which could include Actor, World, String, Array, Integer, Class -- ANY type object (all classes are an extension of the Object class).
You need to login to post a reply.
1
2