This is the problem:
public class ArrayGrid<Sprite> implements Grid<Sprite>
The way you've declared the class, Sprite
is the name of a type parameter. You've made this a generic class, and I suspect you didn't mean to. Within that class, Sprite
refers to the type parameter, not the type - so you could have an ArrayGrid<String>
which implemented Grid<String>
... at which point you'd have a string array rather than a sprite array, so it's no wonder that getSymbol()
wouldn't work, just as one symptom of the problem.
I suspect you just wanted:
public class ArrayGrid implements Grid<Sprite>
At that point, Sprite
really refers to the type. And that means you can avoid the code that wouldn't work around arrays, and instead just write:
this.grid = new Sprite[numRows][numColumns];
Then there's no need to suppress the warnings :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…