Why does the safety of the cast in makeArray
bank on whether user gets access to the array created?
@SuppressWarnings("unchecked")
private E[] makeArray(int s) {
return (E[]) new Object[s];
}
I'm guessing that the user might be able to use the wrong data type if they get a hold of the array. For example, instead of using s
type elements, the user instead uses T
type elements.