Good time of the day to anybody reading,
I would like to ask if the following situation is possible to do in Java:
What do I want to do - create a 2D array which can have different objects in it (i.e. in [0][2] I would like to have PreRoom object, in [0][3] - Room object) and would like these object to be accessible (obviously).
How am I doing this?
1) Declare 2D array of Object type:
Object[][] map = new Object[151][151];
2) Create an object:
map[0][2] = new PreRoom(r, true);
3) But after this I'm unable to use any method of PreRoom/get any its property, i.e. unable to do:
map[0][2].x;
//or
map[0][2].getR;
Am I doing this wrong? Or it's impossible to do and therefore the only solution is to create a unified object for current 2?
Thanks in advance.
EDIT: solution found, thanks for the replies.