2014-08-29 123 views
0

好,那么子类的每个实例,也就是扩展了Tetrimino的J_Tetrimino类,都会得到它自己的int [] [] UP和String方向?父级抽象类中的变量是否由子类继承?

public abstract class Tetrimino { 

// [row][col] 

/*The size of the area a tetrimino needs*/ 
protected final int TETRIMINO_SPACE_SIZE = 3; 

/*The upwards and initial orientation of the J tetrimino*/ 
protected int[][] UP; 

/*The left and second orientation of the J tetrimino*/ 
protected int[][] LEFT; 

/*The down and third orientation of the J tetrimino*/ 
protected int[][] DOWN; 

/*The right and fourth orientation of the J tetrimino*/ 
protected int[][] RIGHT; 

protected String orientation = "UP"; 

public String getCurrentOrientation() { 
    return orientation; 
} 

回答

2

是的。您发布的抽象类的具体实现的每个实例都将获得它自己的这些字段的实例。他们都不是static这将使他们共享。此外,它们全都是protected,所以它们将在子类中可见(除非它们被遮蔽)。

+0

感谢这正是我想知道的! – 2014-08-29 03:20:38