我需要创建对子对象的引用数组。在这种情况下, Room 必须具有对对象的引用数组:DarkRoom
和LightRoom
. 在初始化类型数组的位置出现错误Room
。少了什么东西?
public abstract class Room {
public Room[][] space = new Room[4][4]; // <<Syntax error on token ";",
space[0][0] = new DarkRoom();
space[0][1] = new LightRoom();
space[1][0] = new DarkRoom();
space[1][1] = new LightRoom();
}
public class LightRoom extends Room { ... }
public class DarkRoom extends Room { ... }