so let's say i want to write somthing like an ArrayList just not a list but an ArrayGrid (2 dimensional versioon)
I already figured out that ArrayList uses an Object[] to store data.
so i made an
private Object[][] grid;
but my getData method throws a ClassCastException:
public E[][] getData(){
return (E[][]) grid;
}
The above method and this one:
public E get(int x, int y){
return (E) grid[x][y];
}
both are giving me a warning: "Type safety: Unchecked cast from Object to E"
I can imagine why, but i can't seen to find a solution. So how does ArrayList do that?