2014-08-29 95 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