对不起,因为我是Java初学者......
我想将我在C中完成的以下代码翻译成Java:
#define ROWIMAGES 5
#define COLUMNIMAGES 11
typedef struct {
int posX;
int posY;
int active;
} image;
image images[COLUMNIMAGES][ROWIMAGES];
我正在尝试将其翻译如下:
private static final int ROWIMAGES = 5;
private static final int COLUMNIMAGES = 11;
class image{
int posX;
int posY;
int active;
}
image images[COLUMNIMAGES][ROWIMAGES];
Java中的数组会引发语法错误,出了什么问题?
提前致谢。
答案 0 :(得分:3)
image[][] images = new image[COLUMNIMAGES][ROWIMAGES];
答案 1 :(得分:1)
image[][] images = new image[COLUMNIMAGES][ROWIMAGES]
。在Java中,你必须在数组上调用new。其他提示: