有一个函数,其参数是一个三维数组:
public void setAnimatedView(int[][][] viewFrames){
...
}
有四个二维数组:
public static final int[][] KILL_PLAYER_ANIMATION_FIRST = new int[][]{
{4, 4, 4, 4, 4},
{4, 4, 4, 4, 4},
{4, 4, 4, 4, 4}
};
public static final int[][] KILL_PLAYER_ANIMATION_SECOND = new int[][]{
{4, 0, 4, 0, 4},
{0, 4, 0, 4, 0},
{4, 0, 4, 0, 4}
};
public static final int[][] KILL_PLAYER_ANIMATION_THIRD = new int[][]{
{0, 4, 0, 4, 0},
{4, 0, 4, 0, 4},
{0, 4, 0, 4, 0}
};
public static final int[][] DEAD_PLAYER = new int[][]{
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
};
这是对该函数的调用:
super.setAnimatedView({
{ShapeMatrix.KILL_PLAYER_ANIMATION_FIRST},
{ShapeMatrix.KILL_PLAYER_ANIMATION_SECOND},
{ShapeMatrix.KILL_PLAYER_ANIMATION_THIRD},
{ShapeMatrix.DEAD_PLAYER}});
编译器不允许这样做:“Array initializer is not allowed here”有什么问题?
正确代码: